How C# iterates through Dynamo's geometry

Hello Everyone,

recently I’ve begun a journey with ZeroTouchNodes and TeklaStructures API.
I started with generating beams inside Tekla. With one node I can create beams with the different material, class, profile etc.
BUT the problem appears when I try to modify selected beams (using another node).

This method/node takes Dynamo’s Lines as an input. Then it should assign start/end point of each Dynamo’s line to each Tekla’s beam. However, script takes all beams in Tekla, puts them in one position on every beam’s place. In another words: scrip iterates through Tekla’s beams AND Dynamo’s lines (n x n iterations) BUT it should not be possible (see fro loop). GIF:

You can see how all Tekla’s beams are placed in first Dynamo’s line position and then in second Dyn’s line position, one by one.

  • Does anyone know how to access a list of Dynamo’s lines (geometry objects)?
    Lines cannot be put in foreach loop because “Line does not contain a public instance definition for GetEnumerator”. How does C# is dealing with multiple geometry elements? As I wrote before creating beams in Tekla using Dynamo’s lines work just fine so ‘c#’ iterates somehow by these DynLines.

  • Or maybe Dynamo set somewhere, somehow lancing to crossing? (node’s lancing is set to shortest)

CODE responsible for generating multiple beams in Tekla using Dynamo’s Lines, it’s not even a loop, but it works.

TSG.Point P1 = new TSG.Point(Line.StartPoint.X, Line.StartPoint.Y, Line.StartPoint.Z);
TSG.Point P2 = new TSG.Point(Line.EndPoint.X, Line.EndPoint.Y, Line.EndPoint.Z);
TSM.Beam beam = new TSM.Beam((TSM.Beam.BeamTypeEnum)BeamType);
beam.StartPoint = P1;
beam.EndPoint = P2;
beam.Material.MaterialString = Material;
beam.Profile.ProfileString = Profile;
beam.Class = Class;
MultiOutputPort = new Dictionary<string, object>

Kind Regards

It’s becuase your method expects a single line not a list of ‘lines’. If you input a list of lines into the node, Dynamo’s VM will automatically replicate the method call (i.e. your node), hence all the beams you select in Tekla will be processed against each line in your list (due to Dynamo’s VM behaviour) until it has iterated all the lines in your list.

Instead, change your input type to a list of lines and then you will need to modify your for loop (foreach would be more appropriate for your enumerator object) and you can use your counter to index the list of Dynamo curves. That said your workflow isn’t very robust as there is no control over how you modify each beam with each line, so you might want to rethink your approach entirely.


Bullseye! Thanks.
Now it works.

How is it possible that variable “counter” is 12, whereas list “Line”, has 6 elements (6 lines).
Loop foreach is running twice?


Code bumps up counter twice every time.

1 Like

sorry, I’m blind.

1 Like