Пример #1
0
        /// <summary>
        /// Create a simple house with user interactions.
        /// The user is asked to pick two corners of rectangluar footprint of a house,
        /// then which wall to place a front door.
        /// </summary>
        public static void CreateHouseInteractive(UIDocument uiDoc)
        {
            // (1) Walls
            // Pick two corners to place a house with an orthogonal rectangular footprint
            XYZ pt1 = uiDoc.Selection.PickPoint("Pick the first corner of walls");
            XYZ pt2 = uiDoc.Selection.PickPoint("Pick the second corner");

            // Simply create four walls with orthogonal rectangular profile from the two points picked.
            List <Wall> walls = IntroCs.ModelCreationExport.CreateWalls(uiDoc.Document, pt1, pt2);

            // (2) Door
            // Pick a wall to add a front door to
            SelectionFilterWall selFilterWall = new SelectionFilterWall();
            Reference           r             = uiDoc.Selection.PickObject(ObjectType.Element, selFilterWall, "Select a wall to place a front door");
            Wall wallFront = uiDoc.Document.GetElement(r) as Wall;

            // Add a door to the selected wall
            IntroCs.ModelCreationExport.AddDoor(uiDoc.Document, wallFront);

            // (3) Windows
            // Add windows to the rest of the walls.
            for (int i = 0; i <= 3; i++)
            {
                if (!(walls[i].Id.IntegerValue == wallFront.Id.IntegerValue))
                {
                    IntroCs.ModelCreationExport.AddWindow(uiDoc.Document, walls[i]);
                }
            }

            // (4) Roofs
            // Add a roof over the walls' rectangular profile.

            IntroCs.ModelCreationExport.AddRoof(uiDoc.Document, walls);
        }
        /// <summary>
        /// Selection with wall filter.
        /// See the bottom of the page to see the selection filter implementation.
        /// </summary>
        public void PickWall()
        {
            SelectionFilterWall selFilterWall = new SelectionFilterWall();
            Reference           r             = _uiDoc.Selection.PickObject(ObjectType.Element, selFilterWall, "Select a wall");

            // Show it
            Element e = _uiDoc.Document.GetElement(r);

            ShowBasicElementInfo(e);
        }
        /// <summary>
        /// Create a simple house with user interactions. 
        /// The user is asked to pick two corners of rectangluar footprint of a house, 
        /// then which wall to place a front door. 
        /// </summary>
        public static void CreateHouseInteractive(UIDocument uiDoc)
        {
            using (Transaction transaction = new Transaction(uiDoc.Document))
              {
            transaction.Start("Create House interactive");
            // (1) Walls
            // Pick two corners to place a house with an orthogonal rectangular footprint
            XYZ pt1 = uiDoc.Selection.PickPoint("Pick the first corner of walls");
            XYZ pt2 = uiDoc.Selection.PickPoint("Pick the second corner");

            // Simply create four walls with orthogonal rectangular profile from the two points picked.
            List<Wall> walls = IntroCs.ModelCreationExport.CreateWalls(uiDoc.Document, pt1, pt2);

            // (2) Door
            // Pick a wall to add a front door to
            SelectionFilterWall selFilterWall = new SelectionFilterWall();
            Reference r = uiDoc.Selection.PickObject(ObjectType.Element, selFilterWall, "Select a wall to place a front door");
            Wall wallFront = uiDoc.Document.GetElement(r) as Wall;

            // Add a door to the selected wall
            IntroCs.ModelCreationExport.AddDoor(uiDoc.Document, wallFront);

            // (3) Windows
            // Add windows to the rest of the walls.
            for (int i = 0; i <= 3; i++)
            {
              if (!(walls[i].Id.IntegerValue == wallFront.Id.IntegerValue))
              {
            IntroCs.ModelCreationExport.AddWindow(uiDoc.Document, walls[i]);
              }
            }

            // (4) Roofs
            // Add a roof over the walls' rectangular profile.

            IntroCs.ModelCreationExport.AddRoof(uiDoc.Document, walls);
            transaction.Commit();
              }
        }
        /// <summary>
        /// Selection with wall filter. 
        /// See the bottom of the page to see the selection filter implementation. 
        /// </summary>
        public void PickWall()
        {
            SelectionFilterWall selFilterWall = new SelectionFilterWall();
              Reference r = _uiDoc.Selection.PickObject(ObjectType.Element, selFilterWall, "Select a wall");

              // Show it
              Element e = _uiDoc.Document.GetElement(r);

              ShowBasicElementInfo(e);
        }