void CommitInstance ( Document doc, IGH_DataAccess DA, int Iteration, Rhino.Geometry.Line line, Autodesk.Revit.DB.FamilySymbol familySymbol, Autodesk.Revit.DB.Level level ) { var element = PreviousElement(doc, Iteration); try { if (element?.Pinned ?? true) { var scaleFactor = 1.0 / Revit.ModelUnits; if (scaleFactor != 1.0) { line = line.Scale(scaleFactor); } if (line.Length < Revit.ShortCurveTolerance) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, string.Format("Parameter '{0}' is too short.", Params.Input[0].Name)); } else if (level == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, string.Format("Parameter '{0}' is mandatory.", Params.Input[2].Name)); } else { if (element is FamilyInstance && familySymbol.Id != element.GetTypeId()) { var newElmentId = element.ChangeTypeId(familySymbol.Id); if (newElmentId != ElementId.InvalidElementId) { element = doc.GetElement(newElmentId); } } if (element is FamilyInstance familyInstance && element.Location is LocationCurve locationCurve) { locationCurve.Curve = line.ToHost(); } else { element = doc.Create.NewFamilyInstance(line.ToHost(), familySymbol, level, Autodesk.Revit.DB.Structure.StructuralType.Column); } } }
void CommitInstance ( Document doc, IGH_DataAccess DA, int Iteration, Rhino.Geometry.Line line, Autodesk.Revit.DB.FamilySymbol familySymbol, Autodesk.Revit.DB.Level level ) { var element = PreviousElement(doc, Iteration); try { if (element?.Pinned ?? true) { var scaleFactor = 1.0 / Revit.ModelUnits; if (scaleFactor != 1.0) { line = line.Scale(scaleFactor); } if (line.Length < Revit.ShortCurveTolerance) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, string.Format("Parameter '{0}' is too short.", Params.Input[0].Name)); } else if (level == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, string.Format("Parameter '{0}' is mandatory.", Params.Input[2].Name)); } else { element = doc.Create.NewFamilyInstance(line.ToHost(), familySymbol, level, Autodesk.Revit.DB.Structure.StructuralType.Column); } } } catch (Exception e) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); } finally { ReplaceElement(doc, DA, Iteration, element); } }
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(); }
void CommitInstance ( Document doc, IGH_DataAccess DA, int Iteration, Rhino.Geometry.Line line, Autodesk.Revit.DB.FamilySymbol familySymbol, Autodesk.Revit.DB.Level level ) { var element = PreviousElement(doc, Iteration); if (!element?.Pinned ?? false) { ReplaceElement(doc, DA, Iteration, element); } else { try { var scaleFactor = 1.0 / Revit.ModelUnits; if (scaleFactor != 1.0) { line = line.Scale(scaleFactor); } if (line.Length < Revit.ShortCurveTolerance) { throw new Exception(string.Format("Parameter '{0}' is too short.", Params.Input[0].Name)); } if (level == null) { throw new Exception(string.Format("Parameter '{0}' is mandatory.", Params.Input[2].Name)); } if (element is FamilyInstance && familySymbol.Id != element.GetTypeId()) { var newElmentId = element.ChangeTypeId(familySymbol.Id); if (newElmentId != ElementId.InvalidElementId) { element = doc.GetElement(newElmentId); } } if (element is FamilyInstance familyInstance && element.Location is LocationCurve locationCurve) { locationCurve.Curve = line.ToHost(); } else { element = CopyParametersFrom(doc.Create.NewFamilyInstance(line.ToHost(), familySymbol, level, Autodesk.Revit.DB.Structure.StructuralType.Column), element); } if (line.Direction.IsParallelTo(Rhino.Geometry.Vector3d.ZAxis) == 0) { element.get_Parameter(BuiltInParameter.SLANTED_COLUMN_TYPE_PARAM).Set((int)SlantedOrVerticalColumnType.CT_EndPoint); } else { element.get_Parameter(BuiltInParameter.SLANTED_COLUMN_TYPE_PARAM).Set((int)SlantedOrVerticalColumnType.CT_Vertical); } ReplaceElement(doc, DA, Iteration, element); }