void ReconstructColumnByCurve ( Document doc, ref Autodesk.Revit.DB.Element element, Rhino.Geometry.Line curve, Optional <Autodesk.Revit.DB.FamilySymbol> type, Optional <Autodesk.Revit.DB.Level> level ) { if (curve.FromZ > curve.ToZ) { curve.Flip(); } var scaleFactor = 1.0 / Revit.ModelUnits; curve = curve.ChangeUnits(scaleFactor); SolveOptionalType(ref type, doc, BuiltInCategory.OST_StructuralColumns, nameof(type)); if (!type.Value.IsActive) { type.Value.Activate(); } SolveOptionalLevel(doc, curve, ref level, out var bbox); // Type ChangeElementTypeId(ref element, type.Value.Id); if (element is FamilyInstance familyInstance && element.Location is LocationCurve locationCurve) { locationCurve.Curve = curve.ToHost(); }
protected override void SolveInstance(IGH_DataAccess DA) { Rhino.Geometry.Line axis = Rhino.Geometry.Line.Unset; if (DA.GetData("Axis", ref axis)) { if (axis.FromZ > axis.ToZ) { axis.Flip(); } } FamilySymbol familySymbol = null; if (!DA.GetData("FamilyType", ref familySymbol) && Params.Input[1].Sources.Count == 0) { familySymbol = Revit.ActiveDBDocument.GetElement(Revit.ActiveDBDocument.GetDefaultFamilyTypeId(new ElementId(BuiltInCategory.OST_StructuralColumns))) as FamilySymbol; } if (!familySymbol.IsActive) { familySymbol.Activate(); } Autodesk.Revit.DB.Level level = null; DA.GetData("Level", ref level); if (level == null) { using (var collector = new FilteredElementCollector(Revit.ActiveDBDocument)) { foreach (var levelN in collector.OfClass(typeof(Level)).ToElements().Cast <Level>().OrderBy(c => c.Elevation)) { if (level == null) { level = levelN; } else if (axis.FromZ > levelN.Elevation) { level = levelN; } } } } DA.DisableGapLogic(); int Iteration = DA.Iteration; Revit.EnqueueAction((doc) => CommitInstance(doc, DA, Iteration, axis, familySymbol, level)); }
void ReconstructColumnByCurve ( Document doc, ref Autodesk.Revit.DB.Element element, Rhino.Geometry.Line curve, Optional <Autodesk.Revit.DB.FamilySymbol> type, Optional <Autodesk.Revit.DB.Level> level ) { if (curve.FromZ > curve.ToZ) { curve.Flip(); } var scaleFactor = 1.0 / Revit.ModelUnits; if (scaleFactor != 1.0) { curve = curve.Scale(scaleFactor); } if (curve.Length < Revit.ShortCurveTolerance) { ThrowArgumentException(nameof(curve), "Curve is too short."); } SolveOptionalType(ref type, doc, BuiltInCategory.OST_StructuralColumns, nameof(type)); if (!type.Value.IsActive) { type.Value.Activate(); } SolveOptionalLevel(ref level, doc, curve.FromZ, nameof(level)); // Type ChangeElementTypeId(ref element, type.Value.Id); if (element is FamilyInstance familyInstance && element.Location is LocationCurve locationCurve) { locationCurve.Curve = curve.ToHost(); }