Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private void CreateWall(UIDocument uidoc, Document revitDoc, Application app, List <List <Wall> > RoomsClosedWalls, WallType WallType)
        {
            using (Transaction tx = new Transaction(revitDoc))
            {
                tx.Start("Wall Profile");

                foreach (List <Wall> Wall_C in RoomsClosedWalls)
                {
                    List <WallCollection> WallCurves = new List <WallCollection>();
                    foreach (Wall wall in Wall_C)
                    {
                        WallCollection Walls = GetWallInformation(uidoc, revitDoc, app, wall, WallType);
                        WallCurves.Add(Walls);
                    }

                    int kk = 0;
                    foreach (WallCollection wallC in WallCurves)
                    {
                        try
                        {
                            Wall wall = Wall.Create(revitDoc, wallC.GetAllEdge(), false);
                            wall.WallType = WallType;
                            Element   e  = wall as Element;
                            Parameter PP = e.get_Parameter(BuiltInParameter.DOOR_NUMBER);
                            PP.Set(kk.ToString());
                        }
                        catch (Exception)
                        {
                        }
                        kk++;
                    }
                }

                tx.Commit();
            }
        }