Problem numbering objects

Hello

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?

Thanks!

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.

The problem is that without a filter, if a duct already has an existing name, it gets replaced with the new name.

You had 7 unnumbered ducts.

You ran a graph to number them 1, 2, 3, 4, 5, 6, 7.

Someone deletes duct 6. You now have ducts 1, 2, 3, 4, 5, 7.

Then adds a new duct which is between duct 2 and duct 3. You now have ducts 1, 2, *, 3, 4, 5, 7.

What number do you want the * to be?

If 2 is not in the list, then use 2; but if another 2 is already in the list, then use 8.

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:

  1. 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.

  2. Get the numbers already in use - you have them before your == node so shouldn’t be any instruction required..

  3. 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.

  4. Set the parameter values for the filtered list.

1 Like

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.

It is better when you do show the whole script (preferably with the preview bubbles pinned).

Hard to tell what is happening but just seeing this last part.

NUMERISATION GAINES 4.0.dyn (176.8 KB)

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.

NUMERISATION GAINES.dyn (145.2 KB)

This was the first script I made based on how I wanted it to work, but I realized it wasn’t a good idea to do it that way.

It is better (imo) to post a screenshot of your .dyn (workspace).

image

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.

1 Like
  1. 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.

  2. 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?

I have no idea why you mention this :upside_down_face:.
I only showed an example of how things can be done with less nodes.
The rest is for you to figure out.

You have to get the existing values from your Elements which already have a value.

That I do know.

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.

1 Like