Subtracting/adding if number between range

Hi all!
I working on this script in order to change the Revit family name and rearrange them according to the number of families that are tagged as “not in use”.

Everything works pretty well, but I would like to enhance the last part of the script. As in the jpg “capture2”, I need to subtract 1, 2, 3, etc times according to the range that I set up “capture3”. In this case:

if 4 < list < 7, 1 should be subtracted from the list inside that range;
if 7 < list < 9, 2 should be subtracted from the list inside that range;
if list > 9, 3 should be subtracted from the list;
and so on…

This works good, but If I have 20 family types that are not being used, then I need to add 20 more nodes in order to go through the list and search for items within the range and then subtract.

I would like to know if there is an approach that could be applied to this script in order to make it “automatic” and not being necessary to add more nodes “manually”.

Custom Node

BiggerAndSmallerThan (JC).dyf (3.7 KB)
180320 Familie Name Replace.dyn (54.6 KB)

180320 Familie Name Replace.rvt (1.3 MB)

After learning some basic Python operations I put together this python script:

notInUse = IN[0]
inUse = IN[1]

output =

for item in inUse:
if notInUse[0] < item < notInUse[1]:
output.append(item - 1)
elif notInUse[1] < item < notInUse[2]:
output.append(item - 2)
elif item > notInUse[2]:
output.append(item - 3)
output.append(“outside range”)

OUT = output

It is not entirely automatic, but “cleans” a lot of nodes on my global script.
If helps someone out there, here is the final script.

180326 Familie Name Replace (with python).dyn (36.8 KB)


This is a snippet of design code from a script I was working on for evaluating occupancy loads for spaces surrounding bathrooms to determine the number of fixtures required by code. In general, I try to use design script over python, but that’s just me. You will need to adapt it for your purpose, but you can see the basic:



Does this make sense?

@j.darling thank you for your input.

What I tried to do with the python script was indeed something very similar. Its a simple IF statement based on the elements within one list, affecting the items on the other list.

The difference in the logic is that I pretend not to specify any number(or item) because it varies according to the families that are not being used. That’s why I preferred to make the inputs for the if statement as “the first, second, third, etc item in the list” rather than 0, 40, 70, 100 (as in your example, if I understood well).

I am beginner on scripting and programming. I just made some basic python tutorials and came up with this. :smiley: