Beispiel #1
0
        public static Elements.Element RevitWallToHyparWall(Wall revitWall)
        {
            Polygon        outerPolygon = null;
            List <Polygon> voids        = new List <Polygon>();

            var polygons = revitWall.GetProfile();

            if (polygons == null)
            {
                return(null);
            }

            outerPolygon = polygons[0];
            if (polygons.Count > 1)
            {
                voids.AddRange(polygons.Skip(1));
            }

            //build our profile
            Profile prof = new Profile(outerPolygon, voids, Guid.NewGuid(), "revit Wall");
            //get the location curve as an Elements.Line
            Curve curve = (revitWall.Location as LocationCurve).Curve;
            Line  line  = new Line(curve.GetEndPoint(0).ToVector3(true), curve.GetEndPoint(1).ToVector3(true));

            //return a neat Hypar wall
            return(new WallByProfile(prof, revitWall.Width, line));
        }
Beispiel #2
0
        public static Elements.Element RevitFloorToHyparFloor(Autodesk.Revit.DB.Floor revitFloor)
        {
            Polygon        outerPolygon = null;
            List <Polygon> voids        = new List <Polygon>();
            var            polygons     = revitFloor.GetProfile();

            outerPolygon = polygons[0];
            if (polygons.Count > 1)
            {
                voids.AddRange(polygons.Skip(1));
            }

            //build our profile
            Profile prof  = new Profile(outerPolygon, voids, Guid.NewGuid(), "revit Wall");
            Floor   floor = new Floor(prof, revitFloor.get_Parameter(BuiltInParameter.FLOOR_ATTR_THICKNESS_PARAM).AsDouble());

            //return a neat Hypar floor
            return(floor);
        }
Beispiel #3
0
        public static Space RevitRoomToHyparSpace(Room revitRoom)
        {
            var boundaries = revitRoom.GetBoundarySegments(new SpatialElementBoundaryOptions());

            Polygon        outerLoop = null;
            List <Polygon> voids     = new List <Polygon>();

            for (int i = 0; i < boundaries.Count; i++)
            {
                if (i == 0)
                {
                    var            outer    = boundaries[i];
                    List <Vector3> vertices = new List <Vector3>();
                    foreach (var segment in outer)
                    {
                        vertices.Add(segment.GetCurve().GetEndPoint(0).ToVector3());
                    }
                    outerLoop = new Polygon(vertices);
                }
                else
                {
                    var            inner    = boundaries[i];
                    List <Vector3> vertices = new List <Vector3>();
                    foreach (var segment in inner)
                    {
                        vertices.Add(segment.GetCurve().GetEndPoint(0).ToVector3());
                    }
                    Polygon innerPolygon = new Polygon(vertices);
                    voids.Add(innerPolygon);
                }
            }
            Profile profile = new Profile(outerLoop, voids, Guid.NewGuid(), "Revit Room");
            Space   space   = new Space(profile, revitRoom.UnboundedHeight);

            return(space);
        }
Beispiel #4
0
        public static CurveArray ToRevitCurveArray(this Elements.Geometry.Profile profile, Application app)
        {
            var curveArr = profile.Perimeter.ToRevitCurveArray(app);

            return(curveArr);
        }
Beispiel #5
0
 /// <summary>
 /// Calculate a polygon from the 2d convex hull of a profile.
 /// </summary>
 /// <param name="p">A profile</param>
 /// <returns>A polygon representing the convex hull of the provided shape.</returns>
 public static Polygon FromProfile(Profile p)
 {
     // it's safe to consider only the perimeter because the voids must be within it
     return(FromPolyline(p.Perimeter));
 }