Beispiel #1
0
        /// <summary>
        /// Private constructor to build a DividedPath
        /// </summary>
        /// <param name="c">Host curves</param>
        /// <param name="divs">Number of divisions</param>
        private DividedPath(CurveReference[] c, int divs)
        {
            // PB: This constructor always *recreates* the divided path.
            // Mutating the divided path would require obtaining the referenced
            // curve from the DividedPath, which does not look to be possible
            // (without an expensive reverse lookup)

            // make sure all of the curves are element references
            var curveRefs = c.Select(x => x.InternalReference).ToList();

            TransactionManager.Instance.EnsureInTransaction(Document);

            // build the divided path
            var divPath = Autodesk.Revit.DB.DividedPath.Create( Document, curveRefs );
            divPath.FixedNumberOfPoints = divs;

            // set internally
            InternalSetDividedPath(divPath);

            TransactionManager.Instance.TransactionTaskDone();

            // delete any cached ele and set this new one
            ElementBinder.CleanupAndSetElementForTrace(Document, this.InternalElement);
        }
Beispiel #2
0
        public static DividedPath ByCurveAndDivisions(CurveReference curve, int divisions)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }

            if (divisions < 2)
            {
                throw new Exception("The number of divisions must be greater than 2!");
            }

            return new DividedPath(new[] { curve }, divisions);
        }
Beispiel #3
0
        public static DividedPath ByCurvesAndDivisions(CurveReference[] curves, int divisions)
        {
            if (curves == null)
            {
                throw new ArgumentNullException("curves");
            }

            if (divisions < 2)
            {
                throw new Exception("The number of divisions must be greater than 2!");
            }

            if (curves.Any(x => x == null))
            {
                throw new ArgumentNullException(String.Format("curves[{0}]",  Array.FindIndex(curves, x => x == null)) );
            }

            return new DividedPath(curves, divisions);
        }
Beispiel #4
0
        public static Form ByLoftingCurveReferences( CurveReference[][] curves, bool isSolid )
        {
            var refArrArr = new ReferenceArrayArray();

            foreach (var curveArr in curves)
            {
                var refArr = new ReferenceArray();
                curveArr.ForEach(x => refArr.Append(x.InternalReference));
                refArrArr.Append(refArr);
            }

            return new Form(isSolid, refArrArr);
        }
        /// <summary>
        /// Create an adaptive component referencing the parameters on a Curve reference
        /// </summary>
        /// <param name="parameters">The parameters on the curve</param>
        /// <param name="curveReference">The curve to reference</param>
        /// <param name="familySymbol">The family symbol to construct</param>
        /// <returns></returns>
        public static AdaptiveComponent ByParametersOnCurveReference(double[] parameters, CurveReference curveReference, FamilySymbol familySymbol)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            if (curveReference == null)
            {
                throw new ArgumentNullException("curveReference");
            }

            if (familySymbol == null)
            {
                throw new ArgumentNullException("familySymbol");
            }

            return new AdaptiveComponent(parameters, curveReference.InternalReference, familySymbol);
        }
Beispiel #6
0
        /// <summary>
        /// Create a Reference Point at a parameter on an Curve.  This introduces a persistent relationship between
        /// Elements in the Revit document.
        /// </summary>
        /// <param name="curveReference"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static ReferencePoint ByParameterOnCurveReference(CurveReference curveReference, double parameter)
        {
            if (!Document.IsFamilyDocument)
            {
                throw new Exception("ReferencePoint Elements can only be created in a Family Document");
            }

            if (curveReference == null)
            {
                throw new ArgumentNullException("curveReference");
            }

            return new ReferencePoint(curveReference.InternalReference, parameter, PointOnCurveMeasurementType.NormalizedCurveParameter, PointOnCurveMeasureFrom.Beginning);
        }
Beispiel #7
0
        /// <summary>
        /// Create a Reference Point at a particular length along a curve
        /// </summary>
        /// <param name="curveReference"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static ReferencePoint ByLengthOnCurveReference(CurveReference curveReference, double length)
        {
            if (!Document.IsFamilyDocument)
            {
                throw new Exception("ReferencePoint Elements can only be created in a Family Document");
            }

            if (curveReference == null)
            {
                throw new ArgumentNullException("curveReference");
            }

            return new ReferencePoint(curveReference.InternalReference, length, PointOnCurveMeasurementType.SegmentLength, PointOnCurveMeasureFrom.Beginning);
        }