Create a newopening

Create a newopening

amati_p
Participant Participant
3,923 Views
2 Replies
Message 1 of 3

Create a newopening

amati_p
Participant
Participant

Hi here, I want to create an opening in a wall and I want to know if you have some examples for this. I tried all things that I found on internet and on the forum and nothing worked. Is there someone to help me?

0 Likes
Accepted solutions (1)
3,924 Views
2 Replies
Replies (2)
Message 2 of 3

Mohamed_Arshad
Advisor
Advisor
Accepted solution

HI @amati_p 
Kindly Refer the below code

 

            //Selection of Wall
            Reference refer = uiDoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element);

            //Get Wall
            Wall wall = doc.GetElement(refer) as Wall;


            //Diagonal Corner Points of the Rectangle
            XYZ p1 = new XYZ(500 / 304.8, 0, 500 / 304.8);
            XYZ p2 = new XYZ(1500 / 304.8, 0, 2000 / 304.8);


            //Create Opening
            using (Transaction createOpening=new Transaction(doc,"Create Opening"))
            {
                createOpening.Start();

                doc.Create.NewOpening(wall, p1, p2);

                createOpening.Commit();
            }

 

Other References

https://help.autodesk.com/view/RVT/2014/ESP/?guid=GUID-CA1FB5D9-49BE-40D6-B9AA-BFDE21B10C8D 

https://www.revitapidocs.com/2021.1/06a216d4-2cf6-ec8f-df5b-10f007b70531.htm 

https://spiderinnet.typepad.com/blog/2013/05/revit-net-creations-api-create-floor-and-opening-2nd-tr... 

 

 

 

Hope this Helps 🙂

 


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 3 of 3

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @amati_p ,

In addition to what @arshad99 said, would advise you to start by creating an opening in Revit in UI.
Analyse the opening element using the Revit Lookup tool and get the required points.
Use the points in the NewOpening() method.

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network