Adding trusses to dynamo

Hey guys,

So i’ve been trying to make a script parametrically design a industrial hall made of steel.
Now i’ve got it working (eventually) for a building made form ordinary structural framing.
But i want to add trusses to it too.

Can i do this with the structural truss family, or do i have to sketch it out and using seperate structural framings for all parts?

Structural Trusses are line-based family instances, meaning that for placing them on your project using dynamo, you have to input a location line and a truss family-type (and other info maybe like reference level) to a family instance by line node.

I think im doing something wrong,

But i really cant figure out what…

Could you help me out?

I think you need to use the OOTB node StructuralFraming.BeamByCurve

1 Like

Hello all,

I’m trying the same thing as the topic starter.

But the StructuralFraming.BeamByCurve node doesn’t work.

I tried the FamilyInstance.ByLine from the archilab package,
And the FamilyInstance.ByCurve from the clockwork package.

But in the end it just doesn’t work. Does anyone got a simple explanation?

Hi,

Have you already figured it out?

Apologies for my inaccurate earlier reply. It seems trusses are on their own in terms of element creation.
Please use this code in a python node to create a truss (or trusses). Input 0 needs a LIST of dynamo lines, input 1 needs Truss Family Type. It is assumed that trusses are to be placed on a vertical plane:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
from Autodesk.Revit.DB import Plane as RevitPlane

DynamoLines = IN[0]
Truss_symbol = UnwrapElement(IN[1])


TransactionManager.Instance.EnsureInTransaction(doc)

rvtLines = [i.ToRevitType() for i in DynamoLines]
elements = []
for i in rvtLines:
	pl = RevitPlane.CreateByThreePoints(i.Evaluate(0,True),i.Evaluate(1,True),i.Evaluate(0,True)+XYZ(0,0,1))
	sp = SketchPlane.Create(doc,pl)
	instance = Truss.Create(doc, Truss_symbol.Id,sp.Id,i)
	elements.append(instance)

TransactionManager.Instance.TransactionTaskDone()

OUT = elements

2 Likes

Thx for your reply.

But when i run de script it gave me an error.

okay my mistake, i forgot the List.Create node. It needs a list of lines.

hi,
How would it be possible to make it working on several trusses at the time?
Thanks

Hello everyone,

First of all, thanks to habdirad for the python code. It works really well to create a truss!

To answer SABH, what follows is the python code you need to create multiple trusses starting from a set of lines.

I know your question is from a long time ago, but I am currently working on a Dynamo script that allows the user to create greenhouses. So the creation of trusses became relevant for me as well.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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 *
from Autodesk.Revit.DB import Plane as RevitPlane

# Get the current Revit document
doc = DocumentManager.Instance.CurrentDBDocument

# Inputs from Dynamo
DynamoLines = IN[0]  # List of Dynamo lines representing the truss geometry
Truss_symbol = UnwrapElement(IN[1])  # Truss FamilySymbol

# Start a transaction
TransactionManager.Instance.EnsureInTransaction(doc)

# Convert Dynamo lines to Revit lines
rvtLines = [line.ToRevitType() for line in DynamoLines]

# List to store the created truss elements
elements = []

# Iterate through each Revit line to create a truss
for line in rvtLines:
    # Create a Revit plane using three points
    pl = RevitPlane.CreateByThreePoints(line.Evaluate(0, True), line.Evaluate(1, True), line.Evaluate(0, True) + XYZ(0, 0, 1))
    
    # Create a sketch plane from the Revit plane
    sp = SketchPlane.Create(doc, pl)
    
    # Create the truss instance
    instance = Truss.Create(doc, Truss_symbol.Id, sp.Id, line)
    
    # Append the created truss instance to the elements list
    elements.append(instance)

# End the transaction
TransactionManager.Instance.TransactionTaskDone()

# Output the created truss elements
OUT = elements