Beispiel #1
0
        /// <summary>
        /// Initialize a CableTray element.
        /// </summary>
        private void InitObject(Autodesk.Revit.DB.Electrical.CableTrayType cableTrayType, 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(cableTrayType);
                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.CableTray.Create(DocumentManager.Instance.CurrentDBDocument, cableTrayType.Id, start, end, ElementId.InvalidElementId) as Autodesk.Revit.DB.MEPCurve;
            }

            InternalSetMEPCurve(fi);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.SetElementForTrace(InternalElement);
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CableTray"/> class.
 /// </summary>
 /// <param name="cableTrayType">Type of the cable tray.</param>
 /// <param name="start">The start.</param>
 /// <param name="end">The end.</param>
 internal CableTray(Autodesk.Revit.DB.Electrical.CableTrayType cableTrayType, XYZ start, XYZ end)
 {
     InitObject(cableTrayType, start, end);
 }