How to create colums in Dynamo using the python code block node?

Hi

I have 2 point grids for each level and I would like to create structural columns between each vertical matching point . How could I do this using the python code block?

Any suggestion would be highly appreciated.

Thanks

Hi @mochilas.wayuu14,

I don’t think you need python for this, you can use OOTB nodes to place column families and then edit parameters like height, thickness, etc. afterwards (all in 1 script).

Could you maybe elaborate why you think a python script is needed?

Kind regards,
Daan

2 Likes

I agree - no need for Python here.

https://dictionary.dynamobim.com/#/Revit/Elements/StructuralFraming/Create/ColumnByCurve

Hi , thanks for your answer, I would like to use the python node since I have a script that updates the amount of points every time the number of subdivisions for every portico changes. Every point has its matching pair on the level immediately above it. So I would find it more convenient if I could automatically call the revit api method to create columns inside my script.

Thanks for your suggestion , but I would still find it very useful to use either the preinstalled OOTB nodes or the Revit Api Methods to create the colums inside my python script. Would you happen to know if its possible to use the OOTB nodes inside the python node?

Thanks

import clr 
import sys  
import System 

clr.AddReference("RevitNodes") 

import Revit 
clr.ImportExtensions(Revit.Elements) 
clr.ImportExtensions(Revit.GeometryConversion) 

clr.AddReference("RevitServices") 
import RevitServices 
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference("RevitAPI") 

import Autodesk 
from Autodesk.Revit.DB import * 
from Autodesk.Revit.DB.Structure import *
  

doc = DocumentManager.Instance.CurrentDBDocument 

famType=UnwrapElement(IN[0])# get the column family type to use

columns=FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_StructuralColumns).WhereElementIsElementType().ToElements()#get all column types

levels=FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()#get all levels

for column in columns: #get all column types and select a specific type for the new column
	column_name=column.get_Parameter(BuiltInParameter.ALL_MODEL_FAMILY_NAME).AsString()
	if column_name=="Pilar HEB":#select the appropriate column name
		column_type=column
		
TransactionManager.Instance.EnsureInTransaction(doc)


if famType.IsActive == False:#sometimes you need to first activate the familysymbol for the column type that you are using
	famType.Activate()
	doc.Regenerate()

column_=doc.Create.NewFamilyInstance(XYZ(20,0,levels[0].Elevation),columns[0],levels[0],Structure.StructuralType.Column)
top_offset=column_.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM)
top_offset.Set(0)#set to no offset from level immediately above


TransactionManager.Instance.TransactionTaskDone()


OUT=column_