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(ElementCurveReference[] 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);
        }
 private static ElementCurveReference TryGetCurveReference(ElementCurveReference elementCurveObject)
 {
     return elementCurveObject;
 }
Beispiel #3
0
 public static Form ByLoftCrossSections(ElementCurveReference[][] curves, bool isSolid = true)
 {
     if (curves == null) throw new ArgumentNullException("curves");
     return ByLoftMultiPartCrossSectionsInternal(curves, isSolid);
 }
 private static ElementCurveReference TryGetCurveReference(ElementCurveReference elementCurveObject)
 {
     return(elementCurveObject);
 }
Beispiel #5
0
        public static AdaptiveComponent ByParametersOnCurveReference(double[] parameters, ElementCurveReference revitCurve, FamilySymbol familySymbol)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

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

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

            return new AdaptiveComponent(parameters, ElementCurveReference.TryGetCurveReference(revitCurve).InternalReference, familySymbol);
        }
Beispiel #6
0
        public static DividedPath ByCurvesAndDivisions(ElementCurveReference[] curveReferences, int divisions)
        {
            if (curveReferences == null)
            {
                throw new ArgumentNullException("curveReferences");
            }

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

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

            return new DividedPath(curveReferences.Select(x => ElementCurveReference.TryGetCurveReference(x)).ToArray(), divisions);
        }
Beispiel #7
0
        public static DividedPath ByCurveAndDivisions(ElementCurveReference element, int divisions)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

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

            return new DividedPath(new[] { ElementCurveReference.TryGetCurveReference(element) }, divisions);
        }
Beispiel #8
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="elementCurveReference"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static ReferencePoint ByParameterOnCurveReference(ElementCurveReference elementCurveReference, double parameter)
        {
            if (!Document.IsFamilyDocument)
            {
                throw new Exception("ReferencePoint Elements can only be created in a Family Document");
            }

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

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

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

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