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. Here is the code.
public void CreateFloor_Case2()
{
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);
profile.Append(arc3);
profile.Append(arc4);
CachedDoc.Create.NewFloor(profile, false);
}
Here is what Revit would give us.
“Can't make Extrusion.”
Obviously, the current Revit .NET API does not allow us to create a floor with an opening using a single Document.Create.NewFloor, totally opposite to what was suggested somewhere else. This simple fact can be easily seen from the Profile parameter actually as it does not seem to have the concept of nested loops. It does not seem to take into account the direction of the only loop either.
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.