We created a variety of Revit elements such as walls, windows, doors, openings, floors, roofs, and levels with different shapes such as rectangular and circular if possible programmatically using Revit .NET API and C# before.
We created an architectural rectangular column successfully, and arranged some columns along a circle/arc earlier. In this post, let’s create some architectural rectangular columns in a rectangular array.
public static List<FamilyInstance> InsertColumnAroundCircle(Document doc, FamilySymbol symbol, Level topLevel, double topOffset, Level baseLevel, double baseOffset, XYZ center, double radius, int num, double startAngle)
{
List<FamilyInstance> list = new List<FamilyInstance>();
for (int i = 0; i < num; i++)
{
double angle = startAngle *Math.PI/180 + Math.PI * 2/num * i;
XYZ location = center + new XYZ(radius * Math.Cos(angle), radius * Math.Sin(angle), center.Z);
FamilyInstance famInst = InsertColumn(doc, symbol,
location,
topLevel, topOffset, baseLevel, baseOffset);
Line axis = doc.Application.Create.NewLine(location, XYZ.BasisZ, false);
ElementTransformUtils.RotateElement(doc, famInst.Id, axis, angle);
list.Add(famInst);
}
return list;
}
Here is the sample caller code.
CachedDoc.Application.Create.NewArc(new Plane(XYZ.BasisZ, new XYZ(10.0, 10.0, 0.0)), 10.0, 0.0, Math.PI * 2);
FamilySymbol symbol = ColumnCreation.GetFirstSymbol(ColumnCreation.FindColumnFamilies(CachedDoc).FirstOrDefault());
IOrderedEnumerable<Level> levels = FindAndSortLevels(CachedDoc);
Level toplevel = levels.Last();
Level baseLevel = levels.ElementAt(levels.Count() - 2);
ColumnCreation.InsertColumnsInRectangularArray(CachedDoc,
symbol,
toplevel,
0.0,
baseLevel,
0.0,
new XYZ(10.0, 10.0, 0.0),
50.0, 40.0, 10, 8);
The resultant architectural rectangular columns along the circle both look good and behave in Revit.
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.