We already discussed the creation of beam and column instances in previous posts. In that post on the beam insertion, we explore setting arbitrary start and end points, but the column is left in its default vertical alignment. Here is a question specifically targeted at the creation of slanted structural columns handled recently by our DevTech AEC workgroup leader Mikako Harada:
Question: I cannot find any help to explain how to create a slanted column through the API. Please explain the process required, i.e.
Answer: The first place to look for information about the various overloads of NewFamilyInstance and related methods in the Revit API is the developer guide included with the Revit SDK:
The developer guide does not explain how to insert a slanted column, however. For that, you have two options: the easiest way to go is to use the NewFamilyInstance overload taking the four arguments Curve, FamilySymbol, Level, and StructuralType. This will allow you to directly create a slanted column. It will place a column with a SlantedOrVerticalColumnType equal to CT_EndPoint.
The other approach is explicit, appears more complex, illustrates what is going on behind the scenes, and also demonstrates which parameters and properties need to be modified to create a slanted column:
You can use the same method to create both vertical and slanted columns. Once the column has been created, you can change its 'Slanted Column Type' property using the built-in parameter SLANTED_COLUMN_TYPE_PARAM. You can set it to SlantedOrVerticalColumnType CT_EndPoint, CT_Angle, or CT_Vertical. Once you set the column to a slanted type, the location property becomes a curve, which you can use to set its start and end points. Here is a snippet of sample code to achieve these steps:
Public Function Execute( _ ByVal commandData As ExternalCommandData, _ ByRef message As String, _ ByVal elements As ElementSet) _ As IExternalCommand.Result _ Implements IExternalCommand.Execute Dim app As Application = commandData.Application Dim doc As Document = app.ActiveDocument '' you may want to use your own function '' to find these values in your context. Dim beamType As FamilySymbol = findSymbol(app) Dim topLevel As Level = findLevel(app) Dim startPoint As New XYZ(0.0, 0.0, 0.0) Dim endPoint As New XYZ(100.0, 100.0, 100.0) Dim structuralType As StructuralType = StructuralType.Column '' create a coluemn as normal. '' at this point, column is vertical. Dim strElem As FamilyInstance = doc.Create.NewFamilyInstance( _ startPoint, beamType, topLevel, structuralType) '' set the property to a slanted column Dim param As Parameter = strElem.Parameter( _ BuiltInParameter.SLANTED_COLUMN_TYPE_PARAM) param.Set(SlantedOrVerticalColumnType.CT_EndPoint) '' after setting to a slanted column, '' location should be a curve. Dim strElemCurve As LocationCurve = strElem.Location '' set the start and end point of a curve. If Not (strElemCurve Is Nothing) Then Dim line As Line = app.Create.NewLineBound( _ startPoint, endPoint) strElemCurve.Curve = line End If Return IExternalCommand.Result.Succeeded End Function
To modify an existing vertical column, you can modify the 'Slanted Column Type' property and then set the two end points in a similar fashion.
Many thanks to Mikako for providing this explanation!