Numbering rebar marks & finding duplicates

Hi all,

First of all happy new years.

Im currently working with assemblies with lots of rebar. i need to number these rebar so i can reach a proper rebar list (see pic 1)

The problem is some rebars are duplicates and im unable to do this using just dynamo blocks. So i thought i might aswell give Chatgpt a shot to make me a phyton script.

I tried the script and nothing literally output was 0.

Does anybody have any experience with this? script from chatgpt below.
Prompt:
Looking to build a Python script in side Dynamo for Revit to help with a “match” functionality similar to Excel. Input 1 would be a list of strings that can contain duplicate values. Input 2 would be a 2-dimensional list where the first dimension contains the unique values from Input 1 and the second dimension a simple number. The output should contain a list with the same amount of entries as Input 1 where each item of the list contains the value of the second dimension of input 2, corresponding to the same index as the match between the actual value for that item of Input 1.

def match_functionality(input1, input2):
    # Convert Input 2 into a dictionary for fast lookup
    lookup_dict = {item[0]: item[1] for item in input2}

    # Generate the output list by matching Input 1 values to the dictionary
    output = [lookup_dict.get(value, None) for value in input1]

    return output

# Example inputs
input1 = ["A", "B", "A", "C", "B"]  # List with duplicate values
input2 = [["A", 1], ["B", 2], ["C", 3]]  # 2D list with unique values and corresponding numbers

# Call the function
output = match_functionality(input1, input2)

# Print the output
print(output)

Can you share the script?

Why do you have duplicates / what do you mean by this. My guess there is an (easy?) non Python :snake: solution for this.

Dictionaries and group by keys is what you probably should look into in Dynamo.

Still little unclear what end result you are after.
Also what do the letters (A,B, C etc.) resemble?

PS
I really advice to starting Dynamo first instead of going fir (asking) ChatGPT. I don’t think ChatGPT is that great with just a little Dynamo knowledge. Just my two cents.

1 Like

You don’t output anything from your code. The print() method will print to the console log but that’s not the same as outputting from the node. You need to use OUT to return an output.

OUT = output

Beyond that, I agree with @bvs1982, you need to provide more information and should probably avoid ChatGPT until you know what you’re looking for.

What counts as a duplicate? Nothing in your table looks like a duplicate. How is your data structured? If it doesn’t look like the example inputs then your code won’t work anyway.

my table was just a simple example. the wall elements have a lot more rebar which would go over 40 different types.

So when i tried to auto number (setparameter → mark) i sorted the Ø, length and shape. but because theres duplicates the numbers go over 50 in some elements which isnt handy for productions plans.

Ill share the dynamo file i orginially created shortly. this is the one that doesnt spot duplicates and assigns them the same mark tho

Assembly[Selected]SetParam_Rebar_Mark[Descending]SortByShapes.dyn|attachment (60.6 KB)

i saw something about dictionaries but no clue if thats could be the solution

What I understand is you are trying to create a rebar schedule (sorted by dia, length and then shape), and add a mark value for each row? for example if your assembly has 1500 rebars and after sorting 50 types (rows) are created and you want to number them 1 to 50. is that correct?

1 Like

I still don’t understand the duplicate part in this. Those three properties determine a / the type no?

yes thats correct!

i have a problem finding the right nodes/blocks to do it so thats why i tried chatgpt which didnt work :sweat_smile:

i think rasjesh’s reply explained it quite well. my apologies if i didnt explain it that well.

Got ya. Last question. I see all that …

… in your table, but still unclear what the letters (A, B, C) resemble.

Also, do you have a Revit file for an example?
I still think the solution is in the Group.ByKey node.

https://we.tl/t-uaY10QDJ7x

heres my rvt file (revit 2024) i use

Thats helpfull.

I guess the a, b, c are the the lengths of the different ‘sides’ depending on the shape (I, L, U, Z)?

You wanted them sorted by Bar Length (and Shape and Diameter)?

in my file i sorted them through shape then diameter. so my table would look more organized.

when trying to figure out how to assign duplicate/similar rebars the same mark/number i’ve looked into dictionaries but i dont know where to start.

maybe theres a match functionality node somewhere?

To

?

I used Comments for my test. Could be Mark as well.

1 Like


:point_right: I worked on the same script when I started learning dynamo.
:point_right: You first sort the rebar elements by bar dia parameter and then sort this list by length keeping the list structure same, do the same for next parameter.
:point_right: you will need to play around list levels but here’s a quick tip, the number of elements in the list should be the total number of rebars in your assembly.
:point_right: one thing to note is that do the sorting in dynamo the same way you would in Revit. so the mark values are shown in order.
Add Rebar Mark.dyn (51.5 KB)

1 Like

Sometimes i like to use a ‘barcode’ approach (so i don’t have to sort multiple times).

TEST.dyn (26.6 KB)

1 Like

That is Genius, I love this forum!

As a beginner though it was a great exercise for me. I remember spending nights figuring it out lol

How the sorting would happen though? I guess I could use this approach.

i love what you did there. Thank you guys for all your input.

im going to try and play with the different options tonight so i can practice and learn something from this.

Just to add to this topic. Instead of sorting through Bar Length i’ve sorted through Length Parameters “A”, “B” and “C”. I had an error because some shapes (for example shape 21) had similar bar lengths but different A and B length parameters.

I’ve made some outputs to check how many dupes each rebar mark has. and i have several rebar types (precastembedded, in situ, precastloose) in my project to check if the right types are present and got a mark / number.

I am working out how to combine length parameters a b and c in one sorting progress.

Assembly[Selected]_SetParam_Mark_Rebar.dyn (131.6 KB)