BuildingCoder.CmdListRailingTypes.Execute C# (CSharp) Method

Execute() public method

public Execute ( ExternalCommandData commandData, string &message, ElementSet elements ) : System.Result
commandData ExternalCommandData
message string
elements ElementSet
return System.Result
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
              Document doc = app.ActiveUIDocument.Document;

              // this returns zero symbols:
              //BuiltInCategory bic = BuiltInCategory.OST_StairsRailing;
              //Filter f1 = cf.NewCategoryFilter( bic );
              //Filter f2 = cf.NewTypeFilter( typeof( FamilySymbol ) );
              //Filter f = cf.NewLogicAndFilter( f1, f2 );

              // this returns zero families:
              // we already know why, because family does not implement the Category property, c.f.
              // http://thebuildingcoder.typepad.com/blog/2009/01/family-category-and-filtering.html
              //Filter f1 = cf.NewCategoryFilter( bic );
              //Filter f2 = cf.NewTypeFilter( typeof( Family ) );
              //Filter f = cf.NewLogicAndFilter( f1, f2 );

              BuiltInCategory bic
            = BuiltInCategory.OST_StairsRailingBaluster;

              IList<Element> symbols = Util.GetElementsOfType(
            doc, typeof( FamilySymbol ), bic ).ToElements();

              int n = symbols.Count;

              Debug.Print( "\n{0}"
            + " OST_StairsRailingBaluster"
            + " family symbol{1}:",
            n, Util.PluralSuffix( n ) );

              foreach( FamilySymbol s in symbols )
              {
            Debug.Print(
              "Family name={0}, symbol name={1}",
              s.Family.Name, s.Name );
              }

              bic = BuiltInCategory.OST_StairsRailing;

              symbols = Util.GetElementsOfType(
            doc, typeof( ElementType ), bic ).ToElements();

              n = symbols.Count;

              Debug.Print( "\n{0}"
            + " OST_StairsRailing symbol{1}:",
            n, Util.PluralSuffix( n ) );

              foreach( ElementType s in symbols )
              {
            FamilySymbol fs = s as FamilySymbol;

            Debug.Print(
              "Family name={0}, symbol name={1}",
              null == fs ? "<none>" : fs.Family.Name,
              s.Name );
              }
              return Result.Failed;
        }
CmdListRailingTypes