Exemple #1
0
        /// <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);
        }
Exemple #2
0
        private static Autodesk.Revit.DB.XYZ FindOther(IEnumerable connectors, Autodesk.Revit.DB.Connector closest)
        {
            foreach (Autodesk.Revit.DB.Connector conn in connectors)
            {
                if (closest.Id == conn.Id)
                {
                    continue;
                }

                return(conn.Origin);
            }

            return(null);
        }
Exemple #3
0
        /// <summary>
        /// Initializes the connection.
        /// </summary>
        /// <param name="c1">The first connector.</param>
        /// <param name="c2">The second connector.</param>
        private void InitConnection(Autodesk.Revit.DB.Connector c1, Autodesk.Revit.DB.Connector c2)
        {
            //Phase 2- There was no existing point, create one
            TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);

            if (DocumentManager.Instance.CurrentDBDocument.IsFamilyDocument)
            {
                return;
            }
            else
            {
                c1.ConnectTo(c2);
            }

            TransactionManager.Instance.TransactionTaskDone();
        }
Exemple #4
0
        private static Autodesk.Revit.DB.Connector FindClosest(IEnumerable connectors, Autodesk.Revit.DB.XYZ pt)
        {
            Autodesk.Revit.DB.Connector c = null;
            var closest = 999999.0;

            foreach (Autodesk.Revit.DB.Connector conn in connectors)
            {
                var distance = conn.Origin.DistanceTo(pt);
                if (!(distance <= closest))
                {
                    continue;
                }

                c       = conn;
                closest = distance;
            }

            return(c);
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Fitting"/> class.
        /// </summary>
        /// <param name="c1">The first connector.</param>
        /// <param name="c2">The second connector.</param>
        /// <param name="partType">Type of the part.</param>
        internal Fitting(Autodesk.Revit.DB.Connector c1, Autodesk.Revit.DB.Connector c2, string partType)
        {
            if (partType == "Elbow")
            {
                InitElbowObject(c1, c2);
            }

            if (partType == "Union")
            {
                InitUnionObject(c1, c2);
            }

            if (partType == "Transition")
            {
                InitTransitionObject(c1, c2);
            }

            if (partType == "Connection")
            {
                InitConnection(c1, c2);
            }
        }
Exemple #6
0
 internal Connectors(Autodesk.Revit.DB.Connector conn)
 {
     InternalConnector = conn;
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Fitting"/> class.
 /// </summary>
 /// <param name="c1">The first connector.</param>
 /// <param name="c2">The second connector.</param>
 /// <param name="c3">The third connector.</param>
 /// <param name="c4">The fourth connector.</param>
 internal Fitting(Autodesk.Revit.DB.Connector c1, Autodesk.Revit.DB.Connector c2, Autodesk.Revit.DB.Connector c3, Autodesk.Revit.DB.Connector c4)
 {
     InitCrossObject(c1, c2, c3, c4);
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Fitting"/> class.
 /// </summary>
 /// <param name="c1">The first connector.</param>
 /// <param name="c2">The second connector.</param>
 /// <param name="c3">The third connector.</param>
 internal Fitting(Autodesk.Revit.DB.Connector c1, Autodesk.Revit.DB.Connector c2, Autodesk.Revit.DB.Connector c3)
 {
     InitTeeObject(c1, c2, c3);
 }
Exemple #9
0
 /// <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);
 }