Return a unique value between 0001-1000 if 2 conditions are met

Hello! I am rather new to Dynamo and am in the midst of a school project. I am trying to do the following:
Assign a unique 4 digit code to given elements if the combination of 2 parameters match, not one or the other, but both. Created something out of thin air and it seems to almost work but I am missing something that i cannot identify.


You’ve got a couple good parts, we just need to piece them together properly and fill in the gaps.

There have been a couple discussions already today about searching/matching strings with multiple requirements. I’d suggest taking a look at those, but the main idea is that you want to check both conditions individually and then check a third time to see which elements specifically pass both conditions.

I’d filter your elements first, before creating a unique value. That way you have exactly the number of elements you’re writing to and don’t have to deal with another conditional statement. For the “random” part I’d suggest a Math.RandomList node, specifically one that allows you to set the amount of random values to generate. This does not actually ensure that all the values generated will be unique however. This can be more or less of a problem depending on how many values you’re creating, but we can solve that problem when we get to it.

EDIT: The thing I don’t understand is why you’re comparing the FamilyInstance Level with the Space Name. Those are two different elements with no relation, so you can’t compare them together. Are you wanting to get the Space of the FamilyInstance and compare that way?


Hello, and thanks for the answer :slight_smile:

So the reason I’m comparing the two is less of a comparison, but more of a way to identify and assign the code to the elements I’m targeting. And the reason I’ve used a Space for this is because the model I’m working with is split into 4 parts (A-D), and I did this with Spaces, though I’m not sure if this is the most optimal way. I will try out what you suggested though, and see where it takes me :slight_smile:

My point is that there’s nothing that ties the spaces to the elements. So you have values for the element and values for the space but then use all of those values when writing back to the element. The spaces have nothing to do with the elements so you can’t use them in the analysis of the elements.

Ah, I didn’t realize that. Well that explains why I couldn’t figure out a solution after all this time. How do you suggest I separate the buildings in order to build that connection I was looking for if not with Spaces?

As a temporary but subpar solution, I had to opt to using the All Elements in Active View node and actively filter out elements in schedules as I went on with the codes :confused:

I think you need to get the Spaces from the Elements. That way there is a one-to-one connection between the element and the space you’re checking.