Looping is loopy

My script will take a list of items from a schedule that do not have a “Control Number” assigned to them, look at the last number in the list, add 1, and update the Control Number. I would like to automate this with a loop until my list count of unassigned parameters is 0. I’ve read through what I could find but the LoopWhile and FunctionCompose has me confused. Any guidance would be appreciated.

Jim


Control NumbersWIP.dyn (47.1 KB)

I’m not entirely sure what you’re asking…
Are you wanting the first unassigned one to +1 and then the next to +2 and so on?

Maybe showing what some of the nodes are producing would also be very helpful.

If you’re wanting +1, then +2 and so on you don’t need a loop, you just need lists.

the upper portion of the script is looking for the last number in a list. The format (not my idea) is 001, 002 etc.
The lower portion of the script is looking at another schedule that the values haven’t been assigned yet.
I’m guessing there is an easier way with lists instead of a loop. I’m the only one working with Dynamo, so it’s great to get a totally different perspective from others. Could you explain? Would I use a List.Combine to complete this?

If you’ve already got your items separated - 1 list for assigned and 1 list for unassigned you can keep them separate.
Otherwise use list.combine.

Find items that need a number
Count how many items need a number assigning to them
Make a range from whatever number you want to start with (probably the count of assigned items) to that number + number of unassigned items. You can use a codeblock for that
Then feed the codeblock range in as the parameter value and the list of items needing a parameter as the element.

Obviously you’ll need to make sure your list levels match.

1 Like

I’ll work on this tomorrow and I’ll let you know when I’m successful. Thanks for your guidance.

Jim

1 Like

Hi @mmedia007 & @Alien ,

I agree with Alien’s approach, because mistakes happen easily when trying to filter in this way i created an example with some pseudo inputs (don’t have revit installed on this pc), the logic stays the same though:

(For some reason the camera button in Dynamo didnt work so i made 2 screenshots instead:)


2023-01-06 Fill in Parameters based on Range by Count.dyn (21.5 KB)

Here’s what I ended up with. I was making it way harder than I needed to. It works perfectly. I’m going to add another portion onto this to check for duplicate Control Numbers (if someone copies an element). Should be straight forward. Thanks for everyone’s input and suggestions.

Jim