Beispiel #1
0
        public void GetWallGrossAreaAndRollBack()
        {
            var    testModel = Utils.GetTestModel("walls.rvt");
            var    doc       = xru.OpenDoc(testModel);
            var    walls     = new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls).ToElements();
            var    wall      = walls[0] as Wall;
            double grossArea = 0;

            var inserts = wall.FindInserts(true, true, true, true);

            xru.Run(() =>
            {
                using (Transaction transaction = new Transaction(doc, "Temporary - only to get gross area"))
                {
                    transaction.Start();
                    foreach (ElementId insertId in inserts)
                    {
                        doc.Delete(insertId);
                    }
                    doc.Regenerate();
                    var wallFaceReference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);
                    var face          = doc.GetElement(wallFaceReference.First()).GetGeometryObjectFromReference(wallFaceReference.First()) as PlanarFace;
                    var wallFaceEdges = face.GetEdgesAsCurveLoops();
                    grossArea         = ExporterIFCUtils.ComputeAreaOfCurveLoops(wallFaceEdges);
                    transaction.RollBack();
                }
            }, doc).Wait();



            Assert.True(grossArea > 0);
        }
Beispiel #2
0
        //Nesting the various profiles into a polycurve segments
        private List <ICurve> GetProfiles(DB.CeilingAndFloor floor)
        {
            var  profiles = new List <ICurve>();
            var  faces    = HostObjectUtils.GetTopFaces(floor);
            Face face     = floor.GetGeometryObjectFromReference(faces[0]) as Face;
            var  crvLoops = face.GetEdgesAsCurveLoops();

            foreach (var crvloop in crvLoops)
            {
                var poly = new Polycurve(ModelUnits);
                foreach (var curve in crvloop)
                {
                    var c = curve;

                    if (c == null)
                    {
                        continue;
                    }

                    poly.segments.Add(CurveToSpeckle(c));
                }
                profiles.Add(poly);
            }
            return(profiles);
        }
Beispiel #3
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Document      doc   = uidoc.Document;
            Selection     sel   = uidoc.Selection;

            var wall =
                sel.PickObject(ObjectType.Element, doc.GetSelectionFilter(m => m is Wall)).GetElement(doc) as Wall;

            var facesoutRef = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);
            //HostObjectUtils: Revie.DB命名空间下的类,里面还有获取顶面和底面的方法.
            //ShellLayerType: Revie.DB命名空间下的枚举,Interior = 0,Exterior = 1;
            var facesinRef = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior);

            var faceout = wall.GetGeometryObjectFromReference(facesoutRef.First()) as Face;
            var facein  = wall.GetGeometryObjectFromReference(facesinRef.First()) as Face;

            var area = default(double);

            area += faceout.Area;
            area += facein.Area;
            area  = UnitUtils.ConvertFromInternalUnits(area, DisplayUnitType.DUT_SQUARE_METERS);
            //UnitUtils: Revie.DB命名空间下的静态类,提供了转换单位的静态方法.

            area = Math.Round(area, 3);
            MessageBox.Show(area.ToString() + " m^2");

            return(Result.Succeeded);
        }
Beispiel #4
0
        public static Elements.WallByProfile[] WallsFromRevitWall(ADSK.Wall wall, Document doc)
        {
            var side_faces = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);

            if (side_faces.Count != 1)
            {
                throw new InvalidOperationException($"This wall has ${(side_faces.Count < 1 ? "not enough" : "too many")} interior faces");
            }

            var wallFace = doc.GetElement(side_faces[0]).GetGeometryObjectFromReference(side_faces[0]);

            if (!(wallFace is PlanarFace))
            {
                throw new InvalidCastException("This wall does not have planar faces");
            }

            var wallPlane = wallFace as PlanarFace;
            var profiles  = wallPlane.GetProfiles(true);

            var centerline = (wall.Location as LocationCurve).Curve;

            var line = new ElemGeom.Line(centerline.GetEndPoint(0).ToVector3(true), centerline.GetEndPoint(1).ToVector3(true));

            var walls = profiles.Select(p => new WallByProfile(p.Reverse(),
                                                               Elements.Units.FeetToMeters(wall.Width),
                                                               line));

            return(walls.ToArray());
        }
Beispiel #5
0
        public static List <Spatial.Face3D> BottomProfiles(this HostObject hostObject)
        {
            List <Spatial.Face3D> result = new List <Spatial.Face3D>();

            foreach (Reference reference in HostObjectUtils.GetBottomFaces(hostObject))
            {
                GeometryObject geometryObject = hostObject.GetGeometryObjectFromReference(reference);
                if (geometryObject == null)
                {
                    continue;
                }

                Autodesk.Revit.DB.Face face = geometryObject as Autodesk.Revit.DB.Face;
                if (face == null)
                {
                    continue;
                }

                List <Spatial.Face3D> face3Ds = face.ToSAM();
                if (face3Ds == null || face3Ds.Count == 0)
                {
                    continue;
                }

                result.AddRange(face3Ds);
            }

            return(result);
        }
Beispiel #6
0
        public void getNetWallArea()
        {
            // Get UIDocument
            UIDocument uidoc = _cachedCmdData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            foreach (Wall w in new FilteredElementCollector(doc).OfClass(typeof(Wall)).Cast <Wall>())
            {
                Reference sideFaceRef = HostObjectUtils.GetSideFaces(w, ShellLayerType.Exterior).First();
                Face      netFace     = w.GetGeometryObjectFromReference(sideFaceRef) as Face;

                double netArea = netFace.Area;
                double grossArea;
                using (Transaction t = new Transaction(doc, "delete inserts"))
                {
                    t.Start();

                    foreach (FamilyInstance fi in new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().Where(q => q.Host != null && q.Host.Id == w.Id))
                    {
                        doc.Delete(fi.Id);
                    }

                    doc.Regenerate();

                    Face grossFace = w.GetGeometryObjectFromReference(sideFaceRef) as Face;
                    grossArea = grossFace.Area;
                    createMaterialTakeOffSchedule("Walls-3", new ElementId(BuiltInCategory.OST_Walls));
                    t.RollBack();
                }
                TaskDialog.Show("area", "net = " + netArea + "\nGross = " + grossArea);
            }
        }
Beispiel #7
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;
            Selection  sel   = uidoc.Selection;

            Floor currentFloor = doc.GetElement(sel.PickObject(ObjectType.Element, new FloorSelectionFilter(), "Selecione um piso")) as Floor;

            IList <Reference> topFaceReferenceList = HostObjectUtils.GetTopFaces(currentFloor);

            using (Transaction t = new Transaction(doc, "Criar plataformas"))
            {
                t.Start();
                foreach (Reference currentRef in topFaceReferenceList)
                {
                    Face currentFace = GetFaceFromReference(currentRef, currentFloor);
                    CreatePadFromFace(currentFace, currentFloor, doc);
                }
                t.Commit();
            }

            try
            {
            }
            catch (Exception)
            {
            }

            return(Result.Succeeded);
        }
Beispiel #8
0
        private WallCollection GetWallInformation(UIDocument uidoc, Document revitDoc, Application app, Wall wall, WallType WallType)
        {
            Autodesk.Revit.Creation.Document    credoc = revitDoc.Create;
            Autodesk.Revit.Creation.Application creapp = app.Create;
            View view = revitDoc.ActiveView;

            ElementType type  = WallType as ElementType;
            Parameter   b     = type.get_Parameter((BuiltInParameter.WALL_ATTR_WIDTH_PARAM));
            double      width = b.AsDouble() / 2;

            IList <Reference> sideFaces = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);

            Element e2 = revitDoc.GetElement(sideFaces[0]);

            Face face = e2.GetGeometryObjectFromReference(sideFaces[0]) as Face;

            // The normal of the wall external face.
            XYZ normal = face.ComputeNormal(new UV(0, 0));

            // Offset curve copies for visibility.
            Transform offset = Transform.CreateTranslation(width * normal);

            // If the curve loop direction is counter-
            // clockwise, change its color to RED.


            // Get edge loops as curve loops.
            IList <CurveLoop> curveLoops = face.GetEdgesAsCurveLoops();

            // ExporterIFCUtils class can also be used for
            // non-IFC purposes. The SortCurveLoops method
            // sorts curve loops (edge loops) so that the
            // outer loops come first.
            IList <IList <CurveLoop> > curveLoopLoop = ExporterIFCUtils.SortCurveLoops(curveLoops);
            List <List <Curve> >       Walls         = new List <List <Curve> >();
            WallCollection             WCCC          = new WallCollection();

            foreach (IList <CurveLoop> curveLoops2 in curveLoopLoop)
            {
                foreach (CurveLoop curveLoop2 in curveLoops2)
                {
                    // Check if curve loop is counter-clockwise.

                    CurveArray   curves = creapp.NewCurveArray();
                    List <Curve> CC     = new List <Curve>();
                    foreach (Curve curve in curveLoop2)
                    {
                        curves.Append(curve.CreateTransformed(offset));
                        CC.Add(curve.CreateTransformed(offset));
                    }
                    // Create model lines for an curve loop.
                    Walls.Add(CC);
                    WCCC.AddWall(CC);
                }
            }

            return(WCCC);
        }
Beispiel #9
0
        private void SetWindowData(WindowData windowData)
        {
            // Collect existing windows
            List <FamilyInstance> windowElements = _doc.CollectElements <FamilyInstance>(BuiltInCategory.OST_Windows);

            List <FamilyInstance> newTrims = new List <FamilyInstance>();

            _tt.Start();

            // Get existing window sizes
            foreach (FamilyInstance window in windowElements)
            {
                // Get the type of window to retrieve it's data
                Element    wnTp        = _doc.GetElement(window.GetTypeId());
                double     winHt       = wnTp.get_Parameter(BuiltInParameter.WINDOW_HEIGHT).AsDouble();
                double     winWd       = wnTp.get_Parameter(BuiltInParameter.WINDOW_WIDTH).AsDouble();
                HostObject winHost     = window.Host as HostObject;
                Level      winLevel    = (Level)_doc.GetElement(window.LevelId);
                XYZ        winLocation = ((LocationPoint)window.Location).Point;

                string newTypeName = $"{windowData.StyleCategory}-{Math.Round((double)((int)winWd * 12))}-{Math.Round((double)((int)winHt * 12))}";

                window.Symbol = windowData.Types.FirstOrDefault(type => type.Name == newTypeName)
                                ?? CreateWindowType(windowData.Types[0], windowData.StyleCategory, winWd, winHt);

                // Create new window trim at window locations on the exterior face of the host wall if on a window of specific size ranges
                if (windowData.Trim?.Type != null && (winWd > 1.9 && winWd < 5.9) && (winHt > 1.9 && winHt < 5.9))
                {
                    IList <Reference> sideFaces = HostObjectUtils.GetSideFaces(winHost, ShellLayerType.Exterior);
                    Face           face         = _doc.GetElement(sideFaces[0]).GetGeometryObjectFromReference(sideFaces[0]) as Face;
                    UV             uvLoc        = face.Project(winLocation).UVPoint;
                    XYZ            normal       = face.ComputeNormal(uvLoc);
                    XYZ            refDir       = normal.CrossProduct(XYZ.BasisZ);
                    FamilyInstance winTrim      = _doc.Create.NewFamilyInstance(winLocation, (FamilySymbol)windowData.Trim.Type, winHost, StructuralType.NonStructural);

                    newTrims.Add(winTrim);

                    // Change the width and height of the newly created trims
                    winTrim.SetParameter("Opening Height", winHt);
                    winTrim.SetParameter("Opening Width", winWd);
                }
            }

            // Setting the parameters for the newly placed window trim
            if (newTrims.Count > 0)
            {
                foreach (FamilyInstance trim in newTrims)
                {
                    trim.SetParameter("Top Profile", windowData.Trim.TopCategory);
                    trim.SetParameter("Bottom Profile", windowData.Trim.BottomCategory);
                    trim.SetParameter("Side Profile", windowData.Trim.SideCategory);
                    trim.SetParameter("Shutter", windowData.ShutterCategory);
                    trim.SetParameter("Top Key", windowData.KeyCategory);
                }
            }

            _tt.Commit();
        }
Beispiel #10
0
        /// <summary>
        /// This node will return the bottom face or faces for the input host object. This particular method works for ceilings, roofs, or floors.
        /// </summary>
        /// <param name="hostObject">The host object to retrieve bottom faces for.</param>
        /// <returns></returns>
        public static IEnumerable <List <Surface> > BottomSurface(global::Revit.Elements.Element hostObject)
        {
            Autodesk.Revit.DB.HostObject internalHost = hostObject.InternalElement as Autodesk.Revit.DB.HostObject;

            IList <Reference> sideRefs = HostObjectUtils.GetBottomFaces(internalHost);

            List <Autodesk.Revit.DB.Face> exteriorGeometryObjects = new List <Autodesk.Revit.DB.Face>(sideRefs.Select(r => internalHost.GetGeometryObjectFromReference(r)).Cast <Autodesk.Revit.DB.Face>());

            return(exteriorGeometryObjects.Select(g => g.ToProtoType(true).ToList()));
        }
Beispiel #11
0
        static internal IList <EdgeInfo> GetRoofEdgeInfoList(FootPrintRoof currentRoof, bool topFaces = true)
        {
            //TODO see if theres any segmented curves (segmented sketch lines) on the footprint of the roof
            //If yes, ask the user to correct then OR exit the command OR merge the sketchlines

            IList <EdgeInfo> resultingEdgeInfoList = new List <EdgeInfo>();
            IList <EdgeInfo> tempEdgeInfoList      = new List <EdgeInfo>();

            IList <Reference> currentListOfReferences = new List <Reference>();

            if (topFaces)
            {
                currentListOfReferences = HostObjectUtils.GetTopFaces(currentRoof);
            }
            else
            {
                currentListOfReferences = HostObjectUtils.GetBottomFaces(currentRoof);
            }

            IList <PlanarFace> currentListOfFaces = new List <PlanarFace>();

            IsListOfPlanarFaces(currentListOfReferences, currentRoof, out currentListOfFaces);

            IList <Curve> nonDuplicatedEdgeList = GetNonDuplicatedCurvesFromListOfFaces(currentListOfFaces);

            foreach (Curve currentCurve in nonDuplicatedEdgeList)
            {
                tempEdgeInfoList.Add(GetCurveInformation(currentRoof, currentCurve, currentListOfFaces));
            }

            foreach (EdgeInfo currentEdgeInfo in tempEdgeInfoList)
            {
                EdgeInfo newEdgeInfo = currentEdgeInfo;
                newEdgeInfo.RelatedRidgeEaves = GetRidgeInfoList(newEdgeInfo.Edges[0], tempEdgeInfoList);
                resultingEdgeInfoList.Add(newEdgeInfo);
            }

            resultingEdgeInfoList = MergeEdgeCurves(resultingEdgeInfoList);

            //foreach (EdgeInfo currentEdgeInfo in resultingEdgeInfoList)
            //{
            //    if (currentEdgeInfo.Edges.Count > 1)
            //        System.Diagnostics.Debug.WriteLine("Merged Edge");

            //    Document doc = currentEdgeInfo.CurrentRoof.Document;
            //    PlanarFace pfce = currentEdgeInfo.GetRelatedPanels()[0] as PlanarFace;
            //    Plane pl = new Plane(pfce.FaceNormal, pfce.Origin);
            //    SketchPlane skp = SketchPlane.Create(doc, pl);
            //    doc.Create.NewModelCurve(currentEdgeInfo.Curve, skp);
            //}


            return(resultingEdgeInfoList);
        }
Beispiel #12
0
        public static Transform getLocalCoordinates(Element element, Boolean isStruct, UIDocument uidoc)
        {
            Transform transform = null;

            int isstruct = 1;


            if (isStruct == true)
            {
                isstruct = -1;
            }

            if (element is Wall)
            {
                Wall wall = element as Wall;

                LocationCurve lc   = wall.Location as LocationCurve;
                Line          line = lc.Curve as Line;

                IList <Reference> sideFaces = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior);

                Face face = uidoc.Document.GetElement(sideFaces[0]).GetGeometryObjectFromReference(sideFaces[0]) as Face;

                Reference reference = face.Reference;

                UV uv = new UV(0, 0);

                XYZ wallfacedir = face.ComputeNormal(uv) as XYZ;

                XYZ p = line.GetEndPoint(0);
                XYZ q = line.GetEndPoint(1);
                XYZ v = q - p;

                BoundingBoxXYZ bb   = wall.get_BoundingBox(null);
                double         minZ = bb.Min.Z;
                double         maxZ = bb.Max.Z;

                double w = v.GetLength();
                double h = maxZ - minZ;

                XYZ midpoint = p + 0.5 * v;

                XYZ up = XYZ.BasisZ;

                XYZ walldir = wallfacedir.CrossProduct(up);

                transform        = Transform.Identity;
                transform.Origin = new XYZ(midpoint.X, midpoint.Y, 0);
                transform.BasisX = walldir.Normalize() * isstruct * -1;
                transform.BasisY = up;
                transform.BasisZ = wallfacedir * isstruct;
            }
            return(transform);
        }
 /// <summary>
 /// Return a `StableRepresentation` for a linked wall's exterior face.
 /// </summary>
 public string GetFaceRefRepresentation( 
   Wall wall, 
   Document doc, 
   RevitLinkInstance instance )
 {
   Reference faceRef = HostObjectUtils.GetSideFaces( 
     wall, ShellLayerType.Exterior ).FirstOrDefault();
   Reference stRef = faceRef.CreateLinkReference( instance );
   string stable = stRef.ConvertToStableRepresentation( doc );
   return stable;
 }
Beispiel #14
0
        public void AddFaceBasedFamilyToLinks(Document doc)
        {
            ElementId alignedLinkId = new ElementId(125929);

            // Get symbol

            ElementId symbolId = new ElementId(126580);

            FamilySymbol fs = doc.GetElement(symbolId)
                              as FamilySymbol;

            // Aligned

            RevitLinkInstance linkInstance = doc.GetElement(
                alignedLinkId) as RevitLinkInstance;

            Document linkDocument = linkInstance
                                    .GetLinkDocument();

            FilteredElementCollector wallCollector
                = new FilteredElementCollector(linkDocument);

            wallCollector.OfClass(typeof(Wall));

            Wall targetWall = wallCollector.FirstElement()
                              as Wall;

            Reference exteriorFaceRef
                = HostObjectUtils.GetSideFaces(
                      targetWall, ShellLayerType.Exterior)
                  .First <Reference>();

            Reference linkToExteriorFaceRef
                = exteriorFaceRef.CreateLinkReference(
                      linkInstance);

            Line wallLine = (targetWall.Location
                             as LocationCurve).Curve as Line;

            XYZ wallVector = (wallLine.GetEndPoint(1)
                              - wallLine.GetEndPoint(0)).Normalize();

            using (Transaction t = new Transaction(doc))
            {
                t.Start("Add to face");

                doc.Create.NewFamilyInstance(
                    linkToExteriorFaceRef, XYZ.Zero,
                    wallVector, fs);

                t.Commit();
            }
        }
Beispiel #15
0
        public Face getWallExterior(Wall pickedWall)
        {
            // Get the side faces
            IList <Reference> sideFaces =
                HostObjectUtils.GetSideFaces(pickedWall,
                                             ShellLayerType.Exterior);
            // access the side face
            Face face =
                doc.GetElement(sideFaces[0])
                .GetGeometryObjectFromReference(sideFaces[0]) as Face;

            return(face);
        }
Beispiel #16
0
            public bool AllowElement(Element elem)
            {
                if ((elem as FootPrintRoof) != null)
                {
                    FootPrintRoof currentFootPrintRoof = elem as FootPrintRoof;

                    IList <PlanarFace> pfaces = new List <PlanarFace>();
                    if (Support.IsListOfPlanarFaces(HostObjectUtils.GetTopFaces(currentFootPrintRoof), currentFootPrintRoof, out pfaces))
                    {
                        return(true);
                    }
                }
                return(false);
            }
Beispiel #17
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            if ((uidoc.ActiveView as View3D) == null)
            {
                message = "Por favor, rode este comando em uma vista 3d";
                return(Result.Failed);
            }


            ISelectionFilter ridgeSelectionFilter = new RoofClasses.SelectionFilters.StraightLinesAndFacesRidgeSelectionFilter(doc);
            Reference        currentReference     = uidoc.Selection.PickObject(ObjectType.Edge, ridgeSelectionFilter);

            FootPrintRoof currentFootPrintRoof = doc.GetElement(currentReference) as FootPrintRoof;
            Edge          edge = Support.GetEdgeFromReference(currentReference, currentFootPrintRoof);

            IList <PlanarFace> pfaces = new List <PlanarFace>();

            Support.IsListOfPlanarFaces(HostObjectUtils.GetBottomFaces(currentFootPrintRoof)
                                        , currentFootPrintRoof, out pfaces);

            IList <RoofClasses.EdgeInfo> currentEdgeInfoList = Support.GetRoofEdgeInfoList(currentFootPrintRoof, false);
            Curve currentCurve = Support.GetMostSimilarCurve(edge.AsCurve(), currentEdgeInfoList);

            RoofClasses.EdgeInfo currentInfo = Support.GetCurveInformation(currentFootPrintRoof, currentCurve, pfaces);
            TaskDialog.Show("fac", currentInfo.RoofLineType.ToString());

            Element tTypeElement = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(fsy => fsy is TrussType).ToList().FirstOrDefault();

            if (tTypeElement == null)
            {
                message = "Nenhum tipo de treliça foi encontrada no projeto, por favor, carregue um tipo e rode este comando novamente";
                return(Result.Failed);
            }

            TrussType tType = tTypeElement as TrussType;

            Managers.TrussRidgeManager    currentTrussManager  = new Managers.TrussRidgeManager();
            IList <RoofClasses.TrussInfo> currentTrussInfoList = currentTrussManager.CreateTrussesFromRidgeInfo(currentInfo, tType);

            TaskDialog tDialog = new TaskDialog("Trusses");

            tDialog.MainInstruction = currentTrussInfoList.Count.ToString();
            tDialog.Show();

            return(Result.Succeeded);
        }
Beispiel #18
0
        // Get Profile--------------------------------------------------------------------
        public static List <XYZ> Get_Profile(Document doc, Element element)
        {
            List <XYZ> list_Profile_point = new List <XYZ>();

            try
            {
                IList <Reference> sideFaces = null;
                if (element.Category.Name == "Walls")
                {
                    sideFaces = HostObjectUtils.GetSideFaces(element as Wall, ShellLayerType.Exterior);
                }
                else
                {
                    sideFaces = HostObjectUtils.GetTopFaces(element as Floor);
                }

                Element e2   = doc.GetElement(sideFaces[0]);
                Face    face = e2.GetGeometryObjectFromReference(sideFaces[0]) as Face;

                // The normal of the wall external face.
                XYZ normal = face.ComputeNormal(new UV(0, 0));

                // Get edge loops as curve loops.
                IList <CurveLoop> curveLoops = face.GetEdgesAsCurveLoops();

                // ExporterIFCUtils class can also be used for
                // non-IFC purposes. The SortCurveLoops method
                // sorts curve loops (edge loops) so that the
                // outer loops come first.
                IList <IList <CurveLoop> > curveLoopLoop = ExporterIFCUtils.SortCurveLoops(curveLoops);
                foreach (IList <CurveLoop> curveLoops2 in curveLoopLoop)
                {
                    foreach (CurveLoop curveLoop2 in curveLoops2)
                    {
                        // Check if curve loop is counter-clockwise.
                        bool isCCW = curveLoop2.IsCounterclockwise(normal);
                        foreach (Curve curve in curveLoop2)
                        {
                            list_Profile_point.Add(curve.GetEndPoint(0));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(list_Profile_point);
        }
Beispiel #19
0
        /***************************************************/

        public static List <Plane> PanelPlanes(this Ceiling ceiling)
        {
            List <Plane> result = new List <Plane>();

            foreach (Reference reference in HostObjectUtils.GetBottomFaces(ceiling))
            {
                PlanarFace pf = ceiling.GetGeometryObjectFromReference(reference) as PlanarFace;
                if (pf != null)
                {
                    result.Add(Plane.CreateByNormalAndOrigin(pf.FaceNormal, pf.Origin));
                }
            }

            return(result);
        }
Beispiel #20
0
        /***************************************************/

        public static List <Plane> PanelPlanes(this RoofBase roof)
        {
            List <Plane> result = new List <Plane>();

            foreach (Reference reference in HostObjectUtils.GetTopFaces(roof))
            {
                PlanarFace pf = roof.GetGeometryObjectFromReference(reference) as PlanarFace;
                if (pf != null)
                {
                    result.Add(Plane.CreateByNormalAndOrigin(pf.FaceNormal, pf.Origin));
                }
            }

            return(result);
        }
        /***************************************************/

        public static List <Face> LinkPanelFaces(this Ceiling ceiling, RevitSettings settings)
        {
            List <Face> result = new List <Face>();

            foreach (Reference reference in HostObjectUtils.GetBottomFaces(ceiling))
            {
                PlanarFace pf = ceiling.GetGeometryObjectFromReference(reference) as PlanarFace;
                if (pf != null)
                {
                    result.Add(pf);
                }
            }

            return(result);
        }
        /***************************************************/

        public static List <Face> LinkPanelFaces(this Floor floor, RevitSettings settings)
        {
            List <Face> result = new List <Face>();

            foreach (Reference reference in HostObjectUtils.GetTopFaces(floor))
            {
                PlanarFace pf = floor.GetGeometryObjectFromReference(reference) as PlanarFace;
                if (pf != null)
                {
                    result.Add(pf);
                }
            }

            return(result);
        }
Beispiel #23
0
        public void MirrorWall(Document doc, Wall wall)
        {
            Reference reference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).First();

            //get one of the wall's major side faces
            Face face = wall.GetGeometryObjectFromReference(reference) as Face;

            UV bboxMin = face.GetBoundingBox().Min;
            //create a plane based on the side face with an offset of 10 in the X & Y directions
            Plane plane =
                Plane.CreateByNormalAndOrigin(face.ComputeNormal(bboxMin),
                                              face.Evaluate(bboxMin).Add(new XYZ(10, 10, 0)));

            ElementTransformUtils.MirrorElement(doc, wall.Id, plane);
        }
Beispiel #24
0
        public static List <Curve> GetFloorOuterBoundary(Floor floor)
        {
            Reference rf   = HostObjectUtils.GetTopFaces(floor).First();
            Face      face = floor.GetGeometryObjectFromReference(rf) as Face;

            PlanarFace pface = face as PlanarFace;

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

            List <Curve> profile = GetFaceOuterBoundary(pface);


            return(profile);
        }
Beispiel #25
0
        static internal EdgeInfo GetMostSimilarEdgeInfo(Reference currentReference, Document targetDoc)
        {
            FootPrintRoof currentFootPrintRoof = targetDoc.GetElement(currentReference) as FootPrintRoof;
            Edge          edge = Support.GetEdgeFromReference(currentReference, currentFootPrintRoof);

            IList <PlanarFace> pfaces = new List <PlanarFace>();

            Support.IsListOfPlanarFaces(HostObjectUtils.GetBottomFaces(currentFootPrintRoof)
                                        , currentFootPrintRoof, out pfaces);

            IList <RoofClasses.EdgeInfo> currentEdgeInfoList = GetRoofEdgeInfoList(currentFootPrintRoof, false);

            Curve currentCurve = GetMostSimilarCurve(edge.AsCurve(), currentEdgeInfoList);

            RoofClasses.EdgeInfo currentRidgeInfo = GetCurveInformation(currentFootPrintRoof, currentCurve, pfaces);

            return(currentRidgeInfo);
        }
        /// <summary>Получение наружного Face для стены</summary>
        /// <param name="wall">Стена</param>
        /// <param name="shellLayerType">Тип получаемого Face</param>
        /// <returns></returns>
        public static Face GetSideFaceFromWall(Wall wall, ShellLayerType shellLayerType)
        {
            Face face = null;
            IList <Reference> sideFaces = null;

            if (shellLayerType == ShellLayerType.Exterior)
            {
                sideFaces = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);
            }
            if (shellLayerType == ShellLayerType.Interior)
            {
                sideFaces = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior);
            }
            if (sideFaces != null)
            {
                face = wall.GetGeometryObjectFromReference(sideFaces[0]) as Face;
            }
            return(face);
        }
Beispiel #27
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            var uiapp = commandData.Application;
            var app   = uiapp.Application;
            var uidoc = uiapp.ActiveUIDocument;
            var doc   = uidoc.Document;

            var sel    = uidoc.Selection;
            var acview = uidoc.ActiveView;


            var floor = sel.PickObject(ObjectType.Element, doc.GetSelectionFilter(m => m is Floor)).GetElement(doc) as Floor;

            var faces = HostObjectUtils.GetTopFaces(floor);

            MessageBox.Show(faces.Count.ToString());



            return(Result.Succeeded);
        }
Beispiel #28
0
            public bool AllowReference(Reference reference, XYZ position)
            {
                if (doc == null)
                {
                    return(false);
                }

                Element currentFootPrintElem = doc.GetElement(reference);

                if (currentFootPrintElem == null)
                {
                    return(false);
                }

                FootPrintRoof currentFootPrintRoof = currentFootPrintElem as FootPrintRoof;

                if (currentFootPrintRoof == null)
                {
                    return(false);
                }

                Edge currentEdge = Support.GetEdgeFromReference(reference, currentFootPrintRoof);

                IList <PlanarFace> pfaces = new List <PlanarFace>();

                Support.IsListOfPlanarFaces(HostObjectUtils.GetTopFaces(currentFootPrintRoof), currentFootPrintRoof, out pfaces);

                EdgeInfo currentInfo = Support.GetCurveInformation(currentFootPrintRoof, currentEdge.AsCurve(), pfaces);

                System.Diagnostics.Debug.WriteLine(currentInfo.RoofLineType.ToString());

                if (currentInfo.RoofLineType != RoofLineType.Ridge && currentInfo.RoofLineType != RoofLineType.RidgeSinglePanel)
                {
                    return(false);
                }

                return(true);
            }
Beispiel #29
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Autodesk.Revit.DB.HostObject host = null;
            if (!DA.GetData("Host", ref host) || host is null)
            {
                return;
            }

            var doc = Revit.ActiveDBDocument;

            try
            {
                var bottom = HostObjectUtils.GetBottomFaces(host).Select(reference => new Types.Face(reference, doc));
                DA.SetDataList("Bottom", bottom);
            }
            catch (Autodesk.Revit.Exceptions.ArgumentException) { }

            try
            {
                var top = HostObjectUtils.GetTopFaces(host).Select(reference => new Types.Face(reference, doc));
                DA.SetDataList("Top", top);
            }
            catch (Autodesk.Revit.Exceptions.ArgumentException) { }

            try
            {
                var interior = HostObjectUtils.GetSideFaces(host, ShellLayerType.Interior).Select(reference => new Types.Face(reference, doc));
                DA.SetDataList("Interior", interior);
            }
            catch (Autodesk.Revit.Exceptions.ArgumentException) { }

            try
            {
                var exterior = HostObjectUtils.GetSideFaces(host, ShellLayerType.Exterior).Select(reference => new Types.Face(reference, doc));
                DA.SetDataList("Exterior", exterior);
            }
            catch (Autodesk.Revit.Exceptions.ArgumentException) { }
        }
Beispiel #30
0
        static internal IList <Face> GetEdgeRelatedPanels(Edge targetEdge, FootPrintRoof targetRoof)
        {
            IList <Face> resultingListOfFaces = new List <Face>();
            Face         targetFace0          = targetEdge.GetFace(0);
            Face         targetFace1          = targetEdge.GetFace(1);

            IList <Reference> currentListOfReferences = HostObjectUtils.GetTopFaces(targetRoof).Union(HostObjectUtils.GetBottomFaces(targetRoof)).ToList();

            IList <PlanarFace> targetRoofPlanarFaces = new List <PlanarFace>();

            IsListOfPlanarFaces(currentListOfReferences, targetRoof, out targetRoofPlanarFaces);

            if (targetRoofPlanarFaces.Contains(targetFace0))
            {
                resultingListOfFaces.Add(targetFace0);
            }
            if (targetRoofPlanarFaces.Contains(targetFace1))
            {
                resultingListOfFaces.Add(targetFace1);
            }

            return(resultingListOfFaces);
        }