public FamilyInstance CreateSteelColumnInstance(Document doc, ColumnSt column, FamilySymbol colType, bool isStructural, List<double> storeys) { XYZ location = new XYZ(Util.MmToFoot(column.Location.X), Util.MmToFoot(column.Location.Y), 0); Level colBottomLevel = GetLevel(doc, MapToStorey(column.BottomLevel, storeys)); Level colTopLevel = GetLevel(doc, MapToStorey(column.TopLevel, storeys)); double colRotation = column.RefDirection.X >= 0.0 ? 90 + Vector3D.AngleBetween(new Vector3D(column.RefDirection.X, column.RefDirection.Y, column.RefDirection.Z), new Vector3D(0, -1, 0)) : 90 + Vector3D.AngleBetween(new Vector3D(column.RefDirection.X, column.RefDirection.Y, column.RefDirection.Z), new Vector3D(0, -1, 0)); colRotation *= Math.PI / 180.0; return CreateSteelColumnInstance(doc, location, colBottomLevel, colTopLevel, colType, colRotation, isStructural); }
public FamilySymbol GetIShapeColumnFamilySymbol(Document doc, ColumnSt col, string familyName, BuiltInCategory category) { FamilySymbol fs = new FilteredElementCollector(doc).OfCategory(category) .WhereElementIsElementType() .Cast<FamilySymbol>() .Where(f => f.FamilyName == familyName) .FirstOrDefault(f => { if (f.LookupParameter("Width").AsDouble() == Util.MmToFoot(col.Width) && f.LookupParameter("Height").AsDouble() == Util.MmToFoot(col.Depth) && f.LookupParameter("Flange Thickness").AsDouble() == Util.MmToFoot(col.FlangeTh) && f.LookupParameter("Web Thickness").AsDouble() == Util.MmToFoot(col.WebTh) ) { return true; } return false; }); if (fs != null) return fs; Family family = default; try { fs = new FilteredElementCollector(doc).OfCategory(category) .WhereElementIsElementType() .Cast<FamilySymbol>() .First(f => f.FamilyName == familyName); } catch (Exception) { string directory = $"C:/ProgramData/Autodesk/RVT {revitVersion}/Libraries/US Imperial/Structural Columns/Steel/AISC 14.1/"; family = OpenFamily(doc, directory, familyName); fs = doc.GetElement(family.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol; } ElementType fs1 = fs.Duplicate(String.Format("I-Column Custom {0:0}x{1:0}", col.Width / 10, col.Depth / 10)); fs1.LookupParameter("Width").Set(Util.MmToFoot(col.Width)); fs1.LookupParameter("Height").Set(Util.MmToFoot(col.Depth)); fs1.LookupParameter("Flange Thickness").Set(Util.MmToFoot(col.FlangeTh)); fs1.LookupParameter("Web Thickness").Set(Util.MmToFoot(col.WebTh)); fs1.LookupParameter("Web Fillet").Set(Util.MmToFoot(0.85 * (col.WebTh))); return fs1 as FamilySymbol; }