In Revit .NET API 2013, though the NewWall method has been moved to the Wall class itself, the NewFloor method has not. It is still in the Document.Create instance. Anyway, we figured where it is and were able to create some floors.
In this article, let’s try to create a floor along with an opening inside it again. Here is the code.
public void CreateFloor_Case3()
{
Arc arc1 = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 0, 1), XYZ.Zero), 10, 0, Math.PI);
Arc arc2 = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 0, 1), XYZ.Zero), 10, Math.PI, Math.PI * 2);
Arc arc3 = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 0, 1), XYZ.Zero), 5, 0, Math.PI);
Arc arc4 = CachedDoc.Application.Create.NewArc(new Plane(new XYZ(0, 0, 1), XYZ.Zero), 5, Math.PI, Math.PI * 2);
CurveArray profile = new CurveArray();
profile.Append(arc1);
profile.Append(arc2);
CurveArray profile1 = new CurveArray();
profile1.Append(arc3);
profile1.Append(arc4);
Floor floor = CachedDoc.Create.NewFloor(profile, false);
CachedDoc.Create.NewOpening(floor, profile1, false);
}
Here is what Revit would give us.
“There is a circular chain of references among the highlighted elements.”
As can be seen, we use two different methods to create the floor and the opening respectively this time, but things become trickier. The message sounds quite profound and does not really give us useful clues. By the way, toggling the bPerpendicularFace flag of the NewOpening method, or switching the arc directions would not help at all. The same exception would come up again and again.
We will keep trying to get the looking simple task done but in fact not straightforward at all, using Revit .NET API to create a floor with an opening.
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.