Using an index from LoopWhile

I am trying to export a (single) familytype in a project to DWG and IFC with different parameters (width, Height) which I read from excel.

Therfore I first put the single instance in a single view and read the parameter values in a matrix (list). Then I want to loop through list, updating the parameter values from the list by index number, and export the resulting element in the view before moving to the next index.

I thought I finally got that Loopwhile working, but it isn’t. It is only exporting the last one (which is probably the result).

How do I get this to work driven by the loop index, without creating a cyclic loop…

It’s hard to tell from your explanation if you’re trying to update the same parameter with multiple values and essentially save a snapshot of each value or if you only have one value for each parameter. Regardless, if you want a snapshot of each state of the updated element you’ll have to create a new transaction for each change, which will either mean using Python or splitting up your values into separate exports. The latter is probably the easiest to manage.

FYI the reason this isn’t working is due to how Dynamo executes. Dynamo already iterates through a list automatically, so LoopWhile really isn’t needed. Nodes tend to execute in-line so even if LoopWhile stepped through each item individually it would still have to complete before passing that information on to Set_Parameters. Once all the nodes have executed, Dynamo then commits a single transaction by default. Meaning your data gets written to your DWG all at once. As I said above, the way to get around this is to either write your own Python code to force individual transactions to the DWG or to split your initial list of data into the separate instances that you expect in the end.


i can just post a general issue:

i = IN[0]

OUT = []

while i < 6:
  i += 1
  OUT.append("i is no longer less than 6")

I think you are correct. The issues seems to be I try to do it on a single intance.
Alternatively i tried it with an index list (so each item gets its own index number). The end result is simular, except the output of “intance” in FD25_Set_Parameters does indeed become a list, conaining x times the same instance. That seems to be written x times as the same export file…

The reason I was trying it this way, is that previously I used to create multiple instances, create a view for each instances (where all others are hidden) and export those. However, in this case it would handle about 3500 instances, which litteraly crashes Revit :frowning: . Looks like I will have to make a deep dive into python (which if havent done before)…

You can also “break” your while-loop unitil a certian level. @jpfx

i = IN[0]

OUT = []

while i < 350:
  i += 1

How about process 350 at a time?

Yeah, I will be splitting up the excel file to multiple sheets, then run it multiple times.
Just hoped to get it done quicker (and in just one batch).