Revit .NET API 2013 has moved the Wall Creation APIs to the Wall class as some static methods. It is nice as related stuffs are put together now. People do not have to dig here and there to find something looking simple and natural anymore.
We created some linear, curve, and round walls before, provided some nice help methods, and worked around some Revit .NET API issues accordingly. In this post, let’s create a fancy spiral wall. Here is the whole help class regarding the spiral wall creation.
public class WallCreation
{
public static IOrderedEnumerable<Level> FindAndSortLevels(RvtDocument doc)
{
return new FilteredElementCollector(doc)
.WherePasses(new ElementClassFilter(typeof(Level), false))
.Cast<Level>()
.OrderBy(e => e.Elevation);
}
public static List<ElementId> CreateSpiralWall(Document doc, Level level, XYZ location, XYZ normal, double minRadius, double increment, int rounds)
{
List<ElementId> ids = new List<ElementId>();
for (int i = 0; i < 2 * rounds; i++)
{
double offset, radius, startAngle, endAngle;
radius = minRadius + i * increment;
offset = (i % 2 == 0 ? 0 : 1) * increment;
startAngle = (i % 2 == 0 ? 0 : Math.PI);
endAngle = (i % 2 == 0 ? Math.PI : Math.PI * 2);
XYZ loc = new XYZ(location.X + offset, location.Y, location.Z);
Arc arc1 = doc.Application.Create.NewArc(new Plane(normal, loc), radius, startAngle, endAngle);
Wall wall = Wall.Create(doc, arc1, level.Id, false);
ids.Add(wall.Id);
}
return ids;
}
}
Here is the caller code.
WallCreation.CreateSpiralWall(
CachedDoc,
WallCreation.FindAndSortLevels(CachedDoc).Last(),
new XYZ(0, 0, 0),
new XYZ(0, 0, 1),
5, 5, 5);
Here is the spiral wall in the plan view.
Here is the spiral wall in the 3D view.
Revit Addin Wizard (RevitAddinWizard) provides a variety of 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.