I’m having an issue with my script. The first time I run it, everything works as expected. However, when I add a new duct and run the script again, it seems to start fresh — it doesn’t remember the previous list of ducts.
For example, if I originally have ducts numbered 1, 2, 3, 4, 5, and I delete duct 3 and run the script again, the new ducts are renumbered starting from 1. I end up with something like: 1, 2, 1, 3, 4 — instead of continuing the previous numbering or preserving the original sequence.
How can I make the script retain the existing list and numbering, so it doesn’t reset each time it’s run?
You are filtering out any duct which has a number (anything which isn’t blank) with the List.FilterByBoolMask node. You’ll need to either remove the filter, or come up with a more consistent numbering method.
2 is in the list, but 6 is not. As I understand it you want to have 1, 2, 6, 3, 5, 7. Here is a path forward on that:
Count the number of ducts. Build a range from 1 to that number and convert to strings. Something like (1..List.Count(ducts))+"", though you may have some formatting changes to address.
Get the numbers already in use - you have them before your == node so shouldn’t be any instruction required..
Get the set difference from the range you built and the numbers already used with a List.SetDifference node. The result should be only the numbers not in use, ordered from the lowest to highest.
I didn’t show the entire script, but I have a section that filters based on level, system type, and dimensions. All elements of the same kind should have the same number. It worked the first time I ran the script, but the second time it didn’t, since the list gets reset.
I made some changes. I also wanted to filter it by dimension so that each element with the same dimension would have the same number, but it didn’t work very well.
Most of us probably don’t have a project the specific parameters and such.
PS
I would first fix your( first) problem, then make additional changes.
PPS
Are you sure you are feeding Elements Element.SetParameterValueByName node
(so no empy list there) because the got filtered out because you poupulated
them in your first run. Just spitballing here.
Maintaining the correct order of elements in a list:
If the input list is not properly ordered, the values get mixed up when assigning names because the element IDs don’t match the intended sequence. I need a reliable way to reorder the list correctly before setting the names, so each element keeps its correct association.
Persisting assigned values when adding new elements:
When I assign values like AS_1, AS_2, or AR_1 to elements, I want the system to remember these values. That way, when I add new elements later, the naming continues from the last assigned number instead of resetting or overlapping. How can I implement this kind of value persistence or incremental naming?
Create the list with values as you would do when no duct has a value.
get the values from the ducts that already have a value. and compare the difference in lists.
then filter out the ducts without a value and feed the the difference list to the filtered list of ducts.