public static Element Create(View view, Line line, List <References> references, Element dimType) { if (view == null) { throw new ArgumentNullException(nameof(view)); } if (line == null) { throw new ArgumentNullException(nameof(line)); } if (references == null || !references.Any()) { throw new ArgumentNullException(nameof(references)); } if (dimType == null) { throw new ArgumentNullException(nameof(dimType)); } var v = view.InternalElement as Autodesk.Revit.DB.View; var l = line.ToRevitType() as Autodesk.Revit.DB.Line; var dt = dimType.InternalElement as Autodesk.Revit.DB.DimensionType; var arr = new Autodesk.Revit.DB.ReferenceArray(); foreach (var r in references) { arr.Append(r.InternalElement); } return(new Dimensions(v, l, arr, dt).InternalElement.ToDSType(true)); }
private void InitDimension(Autodesk.Revit.DB.View view, Autodesk.Revit.DB.Line line, Autodesk.Revit.DB.ReferenceArray arr, Autodesk.Revit.DB.DimensionType type) { //Phase 1 - Check to see if the object exists and should be rebound var oldEle = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Dimension>(DocumentManager.Instance.CurrentDBDocument); // Rebind to Element if (oldEle != null) { InternalSetDimension(oldEle); return; } //Phase 2 - There was no existing Element, create new one TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); var ii = DocumentManager.Instance.CurrentDBDocument.Create.NewDimension(view, line, arr, type); InternalSetDimension(ii); TransactionManager.Instance.TransactionTaskDone(); ElementBinder.SetElementForTrace(InternalElement); }
/// protected Dimensions(Autodesk.Revit.DB.View view, Autodesk.Revit.DB.Line line, Autodesk.Revit.DB.ReferenceArray arr, Autodesk.Revit.DB.DimensionType type) { SafeInit(() => InitDimension(view, line, arr, type)); }