Esempio n. 1
0
        /// <summary>
        /// Internal constructor for ReferencePoint Elements that a persistent relationship to a Curve
        /// </summary>
        /// <param name="curveReference"></param>
        /// <param name="parameter"></param>
        /// <param name="measurementType"></param>
        /// <param name="measureFrom"></param>
        private ReferencePoint(Reference curveReference, double parameter, PointOnCurveMeasurementType measurementType,
            PointOnCurveMeasureFrom measureFrom)
        {
            //Phase 1 - Check to see if the object exists and should be rebound
            var oldRefPt =
                ElementBinder.GetElementFromTrace<Autodesk.Revit.DB.ReferencePoint>(Document);

            //There was a point, rebind to that, and adjust its position
            if (oldRefPt != null)
            {
                InternalSetReferencePoint(oldRefPt);
                InternalSetPointOnCurve(curveReference, parameter, measurementType, measureFrom);
                return;
            }

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

            var plc = new PointLocationOnCurve(measurementType, parameter, measureFrom);
            var edgePoint = Document.Application.Create.NewPointOnEdge(curveReference, plc);
            InternalSetReferencePoint(Document.FamilyCreate.NewReferencePoint(edgePoint));

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.SetElementForTrace(this.InternalElement);
        }
Esempio n. 2
0
        /// <summary>
        /// Initialize a ReferencePoint element
        /// </summary>
        /// <param name="curveReference"></param>
        /// <param name="parameter"></param>
        /// <param name="measurementType"></param>
        /// <param name="measureFrom"></param>
        private void InitReferencePoint(Reference curveReference, double parameter, PointOnCurveMeasurementType measurementType,
                                        PointOnCurveMeasureFrom measureFrom)
        {
            //Phase 1 - Check to see if the object exists and should be rebound
            var oldRefPt =
                ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.ReferencePoint>(Document);

            //There was a point, rebind to that, and adjust its position
            if (oldRefPt != null)
            {
                InternalSetReferencePoint(oldRefPt);
                InternalSetPointOnCurve(curveReference, parameter, measurementType, measureFrom);
                return;
            }

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

            var plc       = new PointLocationOnCurve(measurementType, parameter, measureFrom);
            var edgePoint = Document.Application.Create.NewPointOnEdge(curveReference, plc);

            InternalSetReferencePoint(Document.FamilyCreate.NewReferencePoint(edgePoint));

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.SetElementForTrace(InternalElement);
        }
Esempio n. 3
0
        private void InternalSetPointOnCurve(Reference curveReference, double parameter,
                                             PointOnCurveMeasurementType measurementType, PointOnCurveMeasureFrom measureFrom)
        {
            TransactionManager.Instance.EnsureInTransaction(Document);

            var plc       = new PointLocationOnCurve(measurementType, parameter, measureFrom);
            var edgePoint = Document.Application.Create.NewPointOnEdge(curveReference, plc);

            InternalReferencePoint.SetPointElementReference(edgePoint);

            TransactionManager.Instance.TransactionTaskDone();
        }
Esempio n. 4
0
 /// <summary>
 /// Internal constructor for ReferencePoint Elements that a persistent relationship to a Curve
 /// </summary>
 /// <param name="curveReference"></param>
 /// <param name="parameter"></param>
 /// <param name="measurementType"></param>
 /// <param name="measureFrom"></param>
 private ReferencePoint(Reference curveReference, double parameter, PointOnCurveMeasurementType measurementType,
                        PointOnCurveMeasureFrom measureFrom)
 {
     SafeInit(() => InitReferencePoint(curveReference, parameter, measurementType, measureFrom));
 }
Esempio n. 5
0
        private void InternalSetPointOnCurve(Reference curveReference, double parameter,
            PointOnCurveMeasurementType measurementType, PointOnCurveMeasureFrom measureFrom)
        {
            TransactionManager.Instance.EnsureInTransaction(Document);

            var plc = new PointLocationOnCurve(measurementType, parameter, measureFrom);
            var edgePoint = Document.Application.Create.NewPointOnEdge(curveReference, plc);
            InternalReferencePoint.SetPointElementReference(edgePoint);

            TransactionManager.Instance.TransactionTaskDone();
        }