コード例 #1
0
 /// <summary>
 /// Create a Revit Wall from an existing reference
 /// </summary>
 /// <param name="wall"></param>
 /// <param name="isRevitOwned"></param>
 /// <returns></returns>
 internal static Wall FromExisting(Autodesk.Revit.DB.Wall wall, bool isRevitOwned)
 {
     return(new Wall(wall)
     {
         IsRevitOwned = isRevitOwned
     });
 }
コード例 #2
0
        private static void GetGlazingFromWindows(Autodesk.Revit.DB.Wall wall, Autodesk.Revit.DB.Face face, double tolerance, ref List <List <Autodesk.Revit.DB.XYZ> > glazingPts, ref List <double> glazingAreas)
        {
            var doc     = wall.Document;
            var inserts = wall.FindInserts(true, false, true, true).Select(doc.GetElement);

            foreach (var insert in inserts)
            {
                if (insert.Category.Id.IntegerValue == Autodesk.Revit.DB.BuiltInCategory.OST_Windows.GetHashCode())
                {
                    var winPts = GetGeometryPoints(insert);
                    if (!GetPointsOnFace(face, winPts, out var ptsOnFace, out var uvsOnFace))
                    {
                        continue;
                    }
                    if (!GetHull(ptsOnFace, uvsOnFace, tolerance, out var hPts, out var hUvs))
                    {
                        continue;
                    }

                    var winArea  = GetWindowArea(insert);
                    var hullArea = PolygonArea(hUvs);
                    if (hullArea < winArea * 0.5)
                    {
                        continue;
                    }

                    var outerEdges = face.GetEdgesAsCurveLoops().First();
                    foreach (var edge in outerEdges)
                    {
                        for (var i = 0; i < hPts.Count; i++)
                        {
                            var pt = hPts[i];
                            if (edge.Distance(pt) >= 0.01)
                            {
                                continue;
                            }

                            var direction     = (edge.GetEndPoint(1) - edge.GetEndPoint(0)).Normalize();
                            var perpendicular = face.ComputeNormal(new Autodesk.Revit.DB.UV(0.5, 0.5)).CrossProduct(direction);
                            var offset        = 0.1 * perpendicular;
                            var offsetPt      = pt + offset;

                            hPts[i] = offsetPt;
                        }
                    }

                    glazingAreas.Add(PolygonArea(hUvs));
                    glazingPts.Add(hPts);
                }
            }
        }
コード例 #3
0
        private static void GetGlazingFromCurtainWall(Autodesk.Revit.DB.Wall wall, Autodesk.Revit.DB.Face face, double tolerance, ref List <List <Autodesk.Revit.DB.XYZ> > glazingPts, ref List <double> glazingAreas)
        {
            var doc    = wall.Document;
            var cGrid  = wall.CurtainGrid;
            var panels = cGrid.GetPanelIds().Select(x => doc.GetElement(x));

            foreach (var panel in panels)
            {
                var points = GetGeometryPoints(panel);
                if (!GetPointsOnFace(face, points, out var ptsOnFace, out var uvsOnFace))
                {
                    continue;
                }
                if (!GetHull(ptsOnFace, uvsOnFace, tolerance, out var hPts, out var hUvs))
                {
                    continue;
                }

                var outerEdges = face.GetEdgesAsCurveLoops().First();
                foreach (var edge in outerEdges)
                {
                    for (var i = 0; i < hPts.Count; i++)
                    {
                        var pt = hPts[i];
                        if (edge.Distance(pt) >= 0.01)
                        {
                            continue;
                        }

                        var direction     = (edge.GetEndPoint(1) - edge.GetEndPoint(0)).Normalize();
                        var perpendicular = face.ComputeNormal(new Autodesk.Revit.DB.UV(0.5, 0.5)).CrossProduct(direction);
                        var offset        = 0.1 * perpendicular;
                        var offsetPt      = pt + offset;

                        hPts[i] = offsetPt;
                    }
                }

                glazingAreas.Add(PolygonArea(hUvs));
                glazingPts.Add(hPts);
            }
        }
コード例 #4
0
        public static Wall FromRevit(Autodesk.Revit.DB.Wall revitWall)
        {
            var wall = new Wall();

            wall.Thickness = revitWall.Width;

            // note : this will only work with unconnected walls
            // futher logic would be needed to handle the other cases
            wall.Height = revitWall.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsDouble();

            // get the base curve
            var locationCurve = revitWall.Location as Autodesk.Revit.DB.LocationCurve;

            wall.BaseLine = new Line()
            {
                StartPoint = PointInterop.FromRevit(locationCurve.Curve.GetEndPoint(0)),
                EndPoint   = PointInterop.FromRevit(locationCurve.Curve.GetEndPoint(1))
            };

            return(wall);
        }
コード例 #5
0
        public static Dictionary <string, object> ByWallElement(global::Revit.Elements.Wall curtainWall)
        {
            Autodesk.Revit.DB.Document doc          = DocumentManager.Instance.CurrentDBDocument;
            Autodesk.Revit.DB.Wall     internalWall = (Autodesk.Revit.DB.Wall)curtainWall.InternalElement;
            //obtains internal curtain grid
            Autodesk.Revit.DB.CurtainGrid internalCurtainGrid = internalWall.CurtainGrid;
            //gets U Grid Ids
            ICollection <Autodesk.Revit.DB.ElementId> uGridIds = internalCurtainGrid.GetUGridLineIds();
            //make new list for U grids
            List <global::Revit.Elements.Element> uGrids = new List <global::Revit.Elements.Element>(uGridIds.Select(id => doc.GetElement(id).ToDSType(true)).ToArray());
            //gets V Grid Ids
            ICollection <Autodesk.Revit.DB.ElementId> vGridIds = internalCurtainGrid.GetVGridLineIds();
            //make new list for V grids
            List <global::Revit.Elements.Element> vGrids = new List <global::Revit.Elements.Element>(vGridIds.Select(id => doc.GetElement(id).ToDSType(true)).ToArray());
            //returns the outputs
            var outInfo = new Dictionary <string, object>
            {
                { "curtainGrid", internalCurtainGrid },
                { "uGrids", uGrids },
                { "vGrids", vGrids },
            };

            return(outInfo);
        }
コード例 #6
0
 /// <summary>
 /// Create from an existing Revit Element
 /// </summary>
 /// <param name="wall"></param>
 private Wall(Autodesk.Revit.DB.Wall wall)
 {
     InternalSetWall(wall);
 }
コード例 #7
0
 /// <summary>
 /// Set the internal Element, ElementId, and UniqueId
 /// </summary>
 /// <param name="wall"></param>
 private void InternalSetWall(Autodesk.Revit.DB.Wall wall)
 {
     InternalWall      = wall;
     InternalElementId = wall.Id;
     InternalUniqueId  = wall.UniqueId;
 }
コード例 #8
0
 public static Wall FromRhino(Autodesk.Revit.DB.Wall revitWall)
 {
     throw new NotImplementedException();
 }