public void Get_BeamSymbols(Document doc) { ElementClassFilter familyInstanceFilter = new ElementClassFilter(typeof(FamilyInstance)); // Category filter ElementCategoryFilter FramingCategoryfilter = new ElementCategoryFilter(BuiltInCategory.OST_StructuralFraming); // Instance filter LogicalAndFilter FramingInstancesFilter = new LogicalAndFilter(familyInstanceFilter, FramingCategoryfilter); FilteredElementCollector collector = new FilteredElementCollector(doc); // Colletion Array of Elements ICollection <Element> FramingElements = collector.WherePasses(FramingInstancesFilter).ToElements(); foreach (Element e in FramingElements) { FamilyInstance familyInstance = e as FamilyInstance; if (null != familyInstance && familyInstance.StructuralType == StructuralType.Beam) { Element element = e; AnalyticalModel analyticalModel = familyInstance.GetAnalyticalModel(); Curve analyticalCurve = analyticalModel.GetCurve(); XYZ pointStart = analyticalCurve.GetEndPoint(0); XYZ pointEnd = analyticalCurve.GetEndPoint(1); Family family = familyInstance.Symbol.Family; //Create Revit Object and Set Methods RevitObject revitObject = new RevitObject(); revitObject.Set_Element(element); revitObject.Set_AnalyticalModel(analyticalModel); revitObject.Set_PointStart(pointStart); revitObject.Set_PointEnd(pointEnd); revitObject.Set_RevitFamily(family); revitObject.Set_FamilyInstance(familyInstance); _RevitFramingList.Add(revitObject); } } }
public void changeType(Document doc, RevitObject revitObject, EtabObject etabObject, List <FamilySymbol> structuralTypeList) { string _typeName = etabObject._SectionName; FamilySymbol symbol = structuralTypeList.Find(x => x.Name == etabObject._SectionName); // Check to see if element type exist in the project if (symbol == null) { // if element doesn't exist in project method will try to load family. symbol = loadFamily(doc, etabObject); } // Transaction to change the element type Transaction trans = new Transaction(doc, "Edit Type"); trans.Start(); try { FamilyInstance revitFamilyInstance = revitObject.Get_FamilyInstance(); revitFamilyInstance.Symbol = symbol; } catch { } trans.Commit(); }