Exemplo n.º 1
0
        /// <summary>
        /// Initialize a Conduit element
        /// </summary>
        /// <param name="conduitType">Type of the conduit.</param>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        private void InitObject(Autodesk.Revit.DB.Electrical.ConduitType conduitType, XYZ start, XYZ end)
        {
            //Phase 1 - Check to see if the object exists and should be rebound
            var oldFam =
                ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.MEPCurve>(DocumentManager.Instance.CurrentDBDocument);

            //There was a point, rebind to that, and adjust its position
            if (oldFam != null)
            {
                InternalSetMEPCurve(oldFam);
                InternalSetMEPCurveType(conduitType);
                InternalSetPosition(start, end);
                return;
            }

            //Phase 2- There was no existing point, create one
            TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);

            Autodesk.Revit.DB.MEPCurve fi;

            if (DocumentManager.Instance.CurrentDBDocument.IsFamilyDocument)
            {
                fi = null;
            }
            else
            {
                fi = Autodesk.Revit.DB.Electrical.Conduit.Create(DocumentManager.Instance.CurrentDBDocument, conduitType.Id, start, end, ElementId.InvalidElementId);
            }

            InternalSetMEPCurve(fi);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.SetElementForTrace(InternalElement);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Conduit"/> class.
 /// </summary>
 /// <param name="conduitType">Type of the conduit.</param>
 /// <param name="start">The start.</param>
 /// <param name="end">The end.</param>
 internal Conduit(Autodesk.Revit.DB.Electrical.ConduitType conduitType, XYZ start, XYZ end)
 {
     InitObject(conduitType, start, end);
 }