Runnig a Node multiple times

Hello everyone!
I’m attempting to import data from a CSV file and then organize families based on the files content. It’s working smoothly for one of the lines in the CSV file, but I’m facing an issue when I try to loop the function to accommodate multiple placements from the file. I suspect the problem may be either that it removes the first family when it’s trying to place the second one (currently only able to place one family witch is the last line in the CSV-file), or it might not actually be looping properly.
Do you have any ideas or suggestions to resolve this?

@peter.molander ,

how is the list structre of the file ?

do you place FamiliyInstanceByPoint ?

KR

Andreas

Hi,

I think you can take a loot at Element Binding and try to understand it better.

Also take a look at @john_pierson’s video, it explains it and provides a solution:

Hope this helps.

This doesn’t look like an element binding issue, but more like a ‘don’t process things individually but instead as a full collection’ issue. Can’t tell with the anemic portion of the graph and lack of data set though, but likely you should pass all the CSV data along not just individual lines thereof.

1 Like

Saw this and immediately jumped to binding, but makes more sense because the graph is being run once.

@jacob.small
Seems like iterating through data in dynamo is better with list levels and lacing, loops are rarely the way to go, on the canvas environment, as I see.
Maybe I just haven’t encountered a use case and there are some. :man_shrugging:

Use cases for loops would be something like ‘cut the mass in half on it’s long axis until it has a weight less than the maximum allowable size,’ a rare use case for automation, and achievable by other means if you break it down differently.

Design Script and therefore Dynamo’s ability to leverage associative code (unique among languages as most are imperative) makes lists and lacing the path of least resistance.

Certainly, Familybypoint. The GetItemAtIndex function extracts a row from the CSV, and I carry out various calculations to obtain the family’s point and name. The provided image displays only the initial part where I’m attempting to incorporate recursion.

You are absolutely correct that the elements do change when I manually modify the input; therefore, this should not pose an issue (I believe). Here is the entire program, with the code block in between being only temporary.

A thought, though: in typical programming languages, a while loop is used more like this. I don’t think, as you mentioned, that Dynamo is particularly adept at handling this, but I would appreciate the ability to use loops more consistently in the future.

Visual Programming is not the same as textural programming, if you move past textural techniques and embrace nodal techniques you will have an easier time with Dynamo.

Set your CSV to a simple file where the data is readily identifiable; something like this:

1,2,3
A,B,C
4,5,6
D,E,F

Then freeze your intermediate code block and run your graph.
Pin open the results of your ImportCSV, List.Transpose, and List.GetItemAtIndex nodes. If what is happening isn’t clear, post the image showing the results and we can walk you through it with the conceptual dataset.

Here are some of the rows from the CSV. There are currently 18 rows in total, but it’s worth noting that the number of rows may change in the future. Therefor the loop is needed.

Skogsgläntan Äb,1822,1,,,,B-SNF22,VMN_L6,,,Plan 1,BR-1822-01-P01,0.00,BR-1822-01-P01.VMN.1,,,15778.21,53750.60,0.00,70.00,70.00,70.00,Down
Skogsgläntan Äb,1822,1,,,,B-SNF22,VMN_L6,,,Plan 1,BR-1822-01-P01,180.00,BR-1822-01-P01.VMN.2,,,21245.45,21081.54,0.00,70.00,70.00,70.00,Down
Skogsgläntan Äb,1822,1,,,,B-SNF22,VMN_L6,,,Plan 1,BR-1822-01-P01,270.00,BR-1822-01-P01.VMN.3,,,21752.30,31369.30,0.00,70.00,70.00,70.00,Right
Skogsgläntan Äb,1822,1,,,,B-SNF22,VMN_L6,,,Plan 1,BR-1822-01-P01,90.00,BR-1822-01-P01.VMN.4,,,15248.58,31249.68,0.00,70.00,70.00,70.00,Right
Skogsgläntan Äb,1822,1,,,,B-TBB1141,BLK_L6,,,Plan 1,BR-1822-01-P01,0.00,BR-1822-01-P01.BLK.1,,,14633.51,53574.00,0.00,70.00,70.00,70.00,
Skogsgläntan Äb,1822,1,,,,B-TBB1141,BLK_L6,,,Plan 1,BR-1822-01-P01,0.00,BR-1822-01-P01.BLK.2,,,15485.03,43503.39,0.00,70.00,70.00,70.00,

The code block is necessary to generate any results at the moment, and because the index of the required value is fixed, I believe the code block will remain unchanged.

If you require more information or have any further questions, please let me know!

The current implementation results in only one family instance being placed, while it should place one family instance for each corresponding data entry.

As already mentioned, looping in a visual programming language like Dynamo is not the same as looping in a traditional text-based language. Nodes already “loop” based on input structure and length. What you really need to do is focus on list levels, list structure, and list handling in order for your graph to handle all these “datasets” in parallel rather than in series.

Take your time learning the Dynamo Primer and look at other examples of list levels and handling multiple items at a time here in the forum. Once you have these foundational elements figured out things will get much easier.

Example with GetItemAtIndex at different list levels:

2 Likes

As you aren’t certain what structure you have for the CSV, it might be easier to put the headings into the CSV, and build a dictionary of each row. Then as long as your “block name”; “easting”, “westing”, “whatever else” is always present you’ll always get the right values to generate your points.

I’ll see if I can incorporate a “CSV > Family Instances” example sometime later tonight.

1 Like

That would be perfect, tanks!