Applying Lineloads in Dynamo from element


#1

Capture

Hiya!

I’m trying to understand and get to work the script opposite. I should say at the start my programming experience is pretty much limited to Grasshopper so I’m a little over my head.

From what I understand reading the script (and please correct me) I’m declaring 2 strings (beams and force) and two integers (axial and moment). Then I’m ‘getting’ the analytical model from the first input (beams) and assembling new line loads.

Where it’s falling down (and this is a script that was apparently working when it was shared on the forum) is

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 24, in
TypeError: iteration over non-sequence of type FamilyInstance

Line 24 is

an_model = [b.GetAnalyticalModel() for b in beams]

My googling hasn’t suggested anything that I’ve understood, is anyone able to clarify for me?

Cheers

Rob


#2

This is saying that Python is trying to iterate over a non-iterable FamilyInstance. Your input Beams needs to be a list so that it can run for each beam (b) in the list (beams).


#3

Try using a definition like so above your inputs…

def tolist(obj1):
if hasattr(obj1,“iter”): return obj1
else: return [obj1]

And for the input beams write the following…

beams = tolist(UnwrapElement(IN[0]))

This is what I use for inputs to ensure they are an iterable object. Very common point of failure in writing python nodes.

(I can’t seem to format the code on my mobile, but indented code after the first line naturally)


Place filled Region Type
Python Nodes Basics