/// <summary> /// Initializes the takeoff object. /// </summary> /// <param name="c1">The conenctor.</param> /// <param name="curve">The curve.</param> private void InitTakeoffObject(Autodesk.Revit.DB.Connector c1, Autodesk.Revit.DB.MEPCurve curve) { //Phase 1 - Check to see if the object exists and should be rebound var oldFam = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.FamilyInstance>(DocumentManager.Instance.CurrentDBDocument); //There was a point, rebind to that, and adjust its position if (oldFam != null) { InternalSetFamilyInstance(oldFam); return; } //Phase 2- There was no existing point, create one TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); Autodesk.Revit.DB.FamilyInstance fi; if (DocumentManager.Instance.CurrentDBDocument.IsFamilyDocument) { fi = null; } else { fi = DocumentManager.Instance.CurrentDBDocument.Create.NewTakeoffFitting(c1, curve); } InternalSetFamilyInstance(fi); TransactionManager.Instance.TransactionTaskDone(); ElementBinder.SetElementForTrace(InternalElement); }
/// <summary> /// Initializes a new instance of the <see cref="Fitting"/> class. /// </summary> /// <param name="c1">The connector.</param> /// <param name="curve">The curve.</param> internal Fitting(Autodesk.Revit.DB.Connector c1, Autodesk.Revit.DB.MEPCurve curve) { InitTakeoffObject(c1, curve); }