Change Column by Structural Element ID and new section name

Hi,

What would be the easiest way to utilize the API to change columns by their ID into a section with a known section name that can be found in the standard section library?

I am currently working on a workflow where I let FEM design optimize each steel column in my model individually using auto design. I am then exporting the results to xlsx, performing some data wrangling and clustering operations in python. This operations allows me to see what the consequences on material usage would be if you use some “optimal” subset of all the sectons proposed by FEM-design. This is done to reduce the number of types on the building site.
After the clustering analysis is complete, I go through each column with a proposed new section and change them manually. This is tedious and sounds like a basic task if you know FEM-design API.

I would like to automate the task where I find each column by their ID manually (through FIND and typing in the ID manually), and change their section according to my clustering analysis. The results of my analysis can be an excel sheet containing ID, old_section, new_section etc.

I am an intermediate python and Revit with Dynamo user. I only know a few basics of C# and do not have Rhino at my workplace.

Hi,

I realized that there was a way easier way to do this.
I just run auto design with the new subset of sections.

But I guess this workflow can be useful in other situations aswell so I won’t delete the post just yet.

Hi @MagnusFO .

If I have understood correctly, you are basically trying to change the section of a column?

If you do not use Rhino, C# is your option in this case.

The basic idea is to select the column from a model (i.e. using System.Linq library is really simple) and then use the UpdateSection:

var column = model.Entities.Bars.Where(bar => bar.Type == Bars.BarType.Column).Where(bar => bar.Identifier == "MyElementID").First();


var sectionDatabase = Sections.SectionDatabase.GetDefault();
var sectionName = "Concrete sections, Rectangle, 300x900";
var newSection = sectionDatabase.SectionByName(sectionName);

column.UpdateSection( newSection );

var columns = new List<IStructureElement>();
columns.Add(column);

model.AddElements(columns, overwrite: true);

I hope my c# template gives you an idea on how to continue

Hi,

Thanks for responding so quickly!
I was not aware of the Where-method with the Identifier property. Thank you!