/// <summary>
        /// Place a Revit family instance of the given the FamilyType (also known as the FamilySymbol in the Revit API)
        /// on a surface derived from a backing Revit face as reference and a line as reference for its position.
        ///
        /// Note: The FamilyPlacementType must be CurveBased and the input surface must be created from a Revit Face
        /// </summary>
        /// <param name="familyType"></param>
        /// <param name="face">Surface geometry derived from a Revit face as reference element</param>
        /// <param name="line">A line on the face defining where the symbol is to be placed</param>
        /// <returns>FamilyInstance</returns>
        public static FamilyInstance ByFace(FamilyType familyType, Surface face, Autodesk.DesignScript.Geometry.Line line)
        {
            if (familyType == null)
            {
                throw new ArgumentNullException("familyType");
            }
            if (face == null)
            {
                throw new ArgumentNullException("face");
            }
            if (line == null)
            {
                throw new ArgumentNullException("line");
            }
            var reference = ElementFaceReference.TryGetFaceReference(face);

            return(new FamilyInstance(familyType.InternalFamilySymbol, reference.InternalReference, (Line)line.ToRevitType()));
        }
示例#2
0
        public void Faces_ExtractsFacesAccountingForInstanceTransform()
        {
            var ele   = ElementSelector.ByElementId(46874, true);
            var faces = ele.Faces;

            Assert.AreEqual(6, faces.Length);

            var bbox = BoundingBox.ByGeometry(faces);

            bbox.MaxPoint.ShouldBeApproximately(-210.846457, -26.243438, 199.124016, 1e-2);
            bbox.MinPoint.ShouldBeApproximately(-304.160105, -126.243438, 0, 1e-2);

            var refs = faces.Select(x => ElementFaceReference.TryGetFaceReference(x));

            foreach (var refer in refs)
            {
                Assert.AreEqual(46874, refer.InternalReference.ElementId.IntegerValue);
            }
        }
        public static AdaptiveComponent ByParametersOnFace(double[][] uvs, Surface surface, FamilySymbol familySymbol)
        {
            if (uvs == null)
            {
                throw new ArgumentNullException("uvs");
            }

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

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

            return(new AdaptiveComponent(uvs, ElementFaceReference.TryGetFaceReference(surface), familySymbol));
        }
示例#4
0
        /// <summary>
        /// Create a Revit DividedSurface on a face given the face and number of divisions in u and v directon
        /// and the rotation of the grid lines with respect to the natural UV parameterization of the face
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="uDivs"></param>
        /// <param name="vDivs"></param>
        /// <param name="gridRotation"></param>
        /// <returns></returns>
        public static DividedSurface ByFaceUVDivisionsAndRotation(Autodesk.DesignScript.Geometry.Surface surface, int uDivs, int vDivs, double gridRotation)
        {
            if (surface == null)
            {
                throw new ArgumentNullException("surface");
            }

            if (uDivs <= 0)
            {
                throw new Exception("uDivs must be a positive integer");
            }

            if (vDivs <= 0)
            {
                throw new Exception("vDivs must be a positive integer");
            }

            return(new DividedSurface(ElementFaceReference.TryGetFaceReference(surface), uDivs, vDivs, gridRotation));
        }
示例#5
0
        public void Faces_ExtractsFacesAccountingForInstanceTransform()
        {
            var ele   = ElementSelector.ByElementId(46874, true);
            var faces = ele.Faces;

            Assert.AreEqual(6, faces.Length);

            var bbox = BoundingBox.ByGeometry(faces);

            bbox.MaxPoint.ShouldBeApproximately(-64.266, -7.999, 60.693, 1e-3);
            bbox.MinPoint.ShouldBeApproximately(-92.708, -38.479, 0, 1e-3);

            var refs = faces.Select(x => ElementFaceReference.TryGetFaceReference(x));

            foreach (var refer in refs)
            {
                Assert.AreEqual(46874, refer.InternalReference.ElementId.IntegerValue);
            }
        }
示例#6
0
        /// <summary>
        /// Create a Revit DividedSurface on a face given the face and number of divisions in u and v directon
        /// and the rotation of the grid lines with respect to the natural UV parameterization of the face
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="uDivs"></param>
        /// <param name="vDivs"></param>
        /// <param name="gridRotation"></param>
        /// <returns></returns>
        public static DividedSurface ByFaceUVDivisionsAndRotation(Autodesk.DesignScript.Geometry.Surface surface, int uDivs, int vDivs, double gridRotation)
        {
            if (surface == null)
            {
                throw new ArgumentNullException("surface");
            }

            if (uDivs <= 0)
            {
                throw new Exception(string.Format(Properties.Resources.NotPositiveIntegerError, "uDivs"));
            }

            if (vDivs <= 0)
            {
                throw new Exception(string.Format(Properties.Resources.NotPositiveIntegerError, "vDivs"));
            }

            return(new DividedSurface(ElementFaceReference.TryGetFaceReference(surface), uDivs, vDivs, gridRotation));
        }
示例#7
0
        /// <summary>
        /// Create a Revit DividedSurface on a face given the face and number of divisions in u and v directon
        /// and the rotation of the grid lines with respect to the natural UV parameterization of the face
        /// </summary>
        /// <param name="elementFace"></param>
        /// <param name="uDivs"></param>
        /// <param name="vDivs"></param>
        /// <param name="gridRotation"></param>
        /// <returns></returns>
        public static DividedSurface ByFaceUVDivisionsAndRotation(object elementFace, int uDivs, int vDivs, double gridRotation)
        {
            if (elementFace == null)
            {
                throw new ArgumentNullException("elementFace");
            }

            if (uDivs <= 0)
            {
                throw new Exception("uDivs must be a positive integer");
            }

            if (vDivs <= 0)
            {
                throw new Exception("vDivs must be a positive integer");
            }

            return(new DividedSurface(ElementFaceReference.TryGetFaceReference(elementFace), uDivs, vDivs, gridRotation));
        }
示例#8
0
        /// <summary>
        /// Place a Revit family instance given the FamilyType (also known as the FamilySymbol in the Revit API)
        /// on a surface derived from a backing Revit face as reference, a reference direction and a point location where to place the family.
        ///
        /// Note: The FamilyType should be workplane based and the input surface must be created from a Revit Face. The reference direction defines the rotation of the instance on the reference, and thus cannot be perpendicular to the face.
        /// </summary>
        /// <param name="familyType">Family Type. Also called Family Symbol.</param>
        /// <param name="face">Surface geometry derived from a Revit face as reference element</param>
        /// <param name="location">Point on the face where the instance is to be placed</param>
        /// <param name="referenceDirection">A vector that defines the direction of placement of the family instance</param>
        /// <returns>FamilyInstance</returns>
        public static FamilyInstance ByFace(FamilyType familyType, Surface face, Point location,
                                            Vector referenceDirection)
        {
            if (familyType == null)
            {
                throw new ArgumentNullException("familyType");
            }
            if (face == null)
            {
                throw new ArgumentNullException("face");
            }
            if (location == null)
            {
                throw new ArgumentNullException("location");
            }
            if (referenceDirection == null)
            {
                throw new ArgumentNullException("referenceDirection");
            }
            var reference = ElementFaceReference.TryGetFaceReference(face);

            return(new FamilyInstance(familyType.InternalFamilySymbol, reference.InternalReference,
                                      location.ToXyz(), referenceDirection.ToXyz()));
        }
        /// <summary>
        /// Create an adaptive component by uv points on a face.
        /// </summary>
        /// <param name="uvs">An array of UV pairs</param>
        /// <param name="surface">The surface on which to place the AdaptiveComponent</param>
        /// <param name="familySymbol"></param>
        /// <returns></returns>
        public static AdaptiveComponent ByParametersOnFace(Autodesk.DesignScript.Geometry.UV[] uvs, Surface surface, FamilySymbol familySymbol)
        {
            if (uvs == null)
            {
                throw new ArgumentNullException("uvs");
            }

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

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

            return(new AdaptiveComponent(uvs.Select(x => new [] { x.U, x.V }).ToArray(), ElementFaceReference.TryGetFaceReference(surface), familySymbol));
        }
示例#10
0
 /// <summary>
 /// Create a Revit DividedSurface on a face given the face and number of divisions in u and v directon
 /// </summary>
 /// <param name="elementFace"></param>
 /// <param name="uDivs"></param>
 /// <param name="vDivs"></param>
 /// <returns></returns>
 public static DividedSurface ByFaceAndUVDivisions(Autodesk.DesignScript.Geometry.Surface elementFace, int uDivs, int vDivs)
 {
     return(ByFaceUVDivisionsAndRotation(ElementFaceReference.TryGetFaceReference(elementFace), uDivs, vDivs, 0.0));
 }
示例#11
0
 /// <summary>
 /// Create a Revit DividedSurface on a face given the face and number of divisions in u and v directon
 /// </summary>
 /// <param name="elementFace"></param>
 /// <param name="uDivs"></param>
 /// <param name="vDivs"></param>
 /// <returns></returns>
 public static DividedSurface ByFaceAndUVDivisions(object elementFace, int uDivs, int vDivs)
 {
     return(ByFaceUVDivisionsAndRotation(ElementFaceReference.TryGetFaceReference(elementFace), uDivs, vDivs, 0.0));
 }