Quantcast
Channel: RevitNetAddinWizard & NavisworksNetAddinWizard
Viewing all articles
Browse latest Browse all 872

Revit .NET Creations API: Insert an Opening into Wall - Pt. 4 (Circular Opening)

$
0
0

In Revit .NET API 2013, though the NewWall method has been moved to the Wall class itself, the Opening generation method has not. It is still in the Document.Create instance. Anyway, we figured where it is and were able to create some Openings.

In this article, let’s try to create a circular Opening and insert it into a wall. Here is the code.

Arc arc1 = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 1, 0), new XYZ(60, 0, 30)), 5, 0, Math.PI);
Arc arc2 = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 1, 0), new XYZ(60, 0, 30)), 5, Math.PI, Math.PI * 2);
CurveArray profile = new CurveArray();
profile.Append(arc1);
profile.Append(arc2);

Line line = CachedDoc.Application.Create.NewLineBound(new XYZ(50, 0, 0), new XYZ(70, 0, 0));
Wall wall = Wall.Create(CachedDoc, line, FindAndSortLevels(CachedDoc).Last().Id, false); //Level 2 or higher
CachedDoc.Regenerate();
Opening opening = CachedDoc.Create.NewOpening(wall, profile, false);

The following exception would be thrown out no matter how the normal, origin, coordinates, and argument were adjusted.

“Autodesk.Revit.Exceptions.InvalidOperationException
   at Autodesk.Revit.Creation.Document.NewOpening(Element hostElement, CurveArray profile, Boolean bPerpendicularFace) ...”

So the signature having the profile argument of the Document.NewOpening method is not supposed to create openings in walls, though they work for floors as demonstrated before. If anybody has different ideas or findings, welcome to jump in.

Revit Addin Wizard (RevitAddinWizard) provides various wizards, coders and widgets to help program Revit addins. It can be downloaded from the Download link at the bottom of the blog index page.


Viewing all articles
Browse latest Browse all 872

Trending Articles