Repeat a part of script for different elements of a List

Hello Everybody,

I would like to sustitute the node “Select Model Element” for a List that it is taking each element and runing the script presented in the following image. It seems like it is a While Loop but I can’t make with the nodes alredy definied in Dynamo.

Is there any idea?

Lacing and list management should be all that is required for this. No need to beat your head to a pulp trying to set up a loop. Your python will need to be adjusted to group members correctly.

So any idea about how to replace and run the phyton script from string for a List?

Start with a list and see where errors/issues pop up. Most of them can be fixed with lacing. Python will probably have to be modified to take a list but you should be able to find examples all over the forum. Just give it a try and see what happens.

Hi @Asier_de_Celis

"OUT = [UnwrapElement(m).Members for m IN[0]]"

It seems doesn’t work

If your original input was item = IN[0] you’ll have to iterate through your list:

items = IN[0]
for item in items:
     [do this...]

Thank you for the advice. How it is possible to make the for Loop with dynamo nodes in this case, to run the function? Sorry, I’m new in dynamo.

Ah I see. You’re missing an “in”.
"OUT = [UnwrapElement(m).Members for m in IN[0]]"
for m in IN[0]

1 Like

@Nick_Boyts @Asier_de_Celis Sorry i was typing from my phone. I just tested its working fine. Cheers!

1 Like

Thank you so much.

I leave the script just in case someone need.

Finally inside of the phyton script i put this information.

import clr
from Autodesk.DesignScript.Geometry import *
#Las entradas de este nodo se almacenan como lista en las variables IN.
dataEnteringNode = IN

#Asigne la salida a la variable OUT.
OUT = [UnwrapElement(m).Members for m in IN[0]]