Revit.SDK.Samples.TagBeam.CS.TagBeamData.TagBeamData C# (CSharp) Method

TagBeamData() public method

Initializes a new instance of TagBeamData.
public TagBeamData ( ExternalCommandData commandData ) : System
commandData ExternalCommandData An object that is passed to the external application /// which contains data related to the command
return System
        public TagBeamData(ExternalCommandData commandData)
        {
            //Get beams selected
               m_revitDoc = commandData.Application.ActiveUIDocument;
               m_docCreator = m_revitDoc.Document.Create;
               m_view = m_revitDoc.Document.ActiveView;

               SelElementSet elementSet = m_revitDoc.Selection.Elements;
            ElementSetIterator itor = elementSet.ForwardIterator();
            while (itor.MoveNext())
            {
                FamilyInstance familyInstance = itor.Current as FamilyInstance;
                if ((familyInstance != null) && (familyInstance.StructuralType == Autodesk.Revit.DB.Structure.StructuralType.Beam))
                {
                    m_beamList.Add(familyInstance);
                }
            }
            if (m_beamList.Count < 1)
            {
                throw new ApplicationException("there is no beam selected");
            }

            //Get the family symbols of tag in this document.
            FilteredElementCollector collector = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document);
            IList<Element> elements = collector.OfClass(typeof(Family)).ToElements();

            foreach (Family family in elements)
            {
               if (family != null && family.Symbols != null)
               {
                  FamilySymbolSetIterator it = family.Symbols.ForwardIterator();
                  while (it.MoveNext())
                  {
                     try
                     {
                        FamilySymbol tagSymbol = it.Current as FamilySymbol;
                        if (tagSymbol != null)
                        {
                           switch (tagSymbol.Category.Name)
                           {
                              case "Structural Framing Tags":
                                 m_categoryTagTypes.Add(new FamilySymbolWrapper(tagSymbol));
                                 continue;
                              case "Material Tags":
                                 m_materialTagTypes.Add(new FamilySymbolWrapper(tagSymbol));
                                 continue;
                              case "Multi-Category Tags":
                                 m_multiCategoryTagTypes.Add(new FamilySymbolWrapper(tagSymbol));
                                 continue;
                              default:
                                 continue;
                           }
                        }
                     }
                     catch (Exception)
                     {
                        continue;
                     }
                  }
               }
            }
        }