public FamilyInstance CreateInclinedInstance(Document doc, Inclined inclined, FamilySymbol colType, bool isStructural, List<double> storeys) { XYZ location = new XYZ(Util.MmToFoot(inclined.Location.X), Util.MmToFoot(inclined.Location.Y), Util.MmToFoot(inclined.Location.Z)); XYZ endLocation = location + Util.MmToFoot(inclined.Length) * new XYZ(inclined.Axis.X, inclined.Axis.Y, inclined.Axis.Z); Level colBottomLevel = GetLevel(doc, MapToStorey(inclined.BottomLevel, storeys)); double toplevel = Util.FootToMm(endLocation.Z); Level colTopLevel = GetLevel(doc, MapToStorey(toplevel, storeys)); double colRotation = inclined.RefDirection.X >= 0.0 ? 90 + Vector3D.AngleBetween(new Vector3D(inclined.RefDirection.X, inclined.RefDirection.Y, inclined.RefDirection.Z), new Vector3D(0, -1, 0)) : 90 + Vector3D.AngleBetween(new Vector3D(inclined.RefDirection.X, inclined.RefDirection.Y, inclined.RefDirection.Z), new Vector3D(0, -1, 0)); colRotation *= Math.PI / 180.0; return CreateInclinedInstance(doc, location, endLocation, colBottomLevel, colTopLevel, colType, colRotation, isStructural); }
public FamilySymbol GetInclinesFamilySymbol(Document doc, Inclined inclined, string familyName, BuiltInCategory category) { string b = category == BuiltInCategory.OST_StructuralColumns ? "b" : "Width"; string h = category == BuiltInCategory.OST_StructuralColumns ? "h" : "Depth"; FamilySymbol fs = new FilteredElementCollector(doc).OfCategory(category) .WhereElementIsElementType() .Cast<FamilySymbol>() .Where(f => f.FamilyName == familyName) .FirstOrDefault(f => { if (f.LookupParameter(h).AsDouble() == Util.MmToFoot(inclined.Depth) && f.LookupParameter(b).AsDouble() == Util.MmToFoot(inclined.Width)) { 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/Concrete/"; family = OpenFamily(doc, directory, familyName); fs = doc.GetElement(family.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol; } ElementType fs1 = fs.Duplicate(String.Format("Column {0:0}x{1:0}", inclined.Width / 10, inclined.Depth / 10)); fs1.LookupParameter(b).Set(Util.MmToFoot(inclined.Width)); fs1.LookupParameter(h).Set(Util.MmToFoot(inclined.Depth)); return fs1 as FamilySymbol; }