# Numbering rebar marks & finding duplicates

**URL:** <https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [January 6, 2025, 12:29pm UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023 "2025-01-06T12:29:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![niels.van.hove](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@niels.van.hove](https://forum.dynamobim.com/u/niels.van.hove)\
**Post date:** [January 6, 2025, 12:29pm UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/1 "2025-01-06T12:29:17Z")

</div>

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.

```auto
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)

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/5/e5db6abb90169d13bc04d6ae5cb78ccc812ab137.png)

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [January 6, 2025, 6:44pm UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/2 "2025-01-06T18:44:43Z")

</div>

> [@niels.van.hove](#):
>
> I tried the script and nothing literally output was 0.

Can you share the script?

> [@niels.van.hove](#):
>
> The problem is some rebars are duplicates

Why do you have duplicates / what do you mean by this. My guess there is an (easy?) non Python 🐍 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.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 6, 2025, 10:58pm UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/3 "2025-01-06T22:58:29Z")

</div>

> [@niels.van.hove](#):
>
> literally output was 0

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.

---

<div class="post-metadata">

**Author:** ![niels.van.hove](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@niels.van.hove](https://forum.dynamobim.com/u/niels.van.hove)\
**Post date:** [January 7, 2025, 6:27am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/4 "2025-01-07T06:27:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![niels.van.hove](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@niels.van.hove](https://forum.dynamobim.com/u/niels.van.hove)\
**Post date:** [January 7, 2025, 6:30am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/5 "2025-01-07T06:30:30Z")

</div>

[Assembly[Selected]_SetParam\_Rebar\_Mark_[Descending]SortByShapes.dyn|attachment](https://forum.dynamobim.com/uploads/short-url/dK7f4bE3pa0o92wPA2it1s9zDLJ.dyn) (60.6 KB)

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

---

<div class="post-metadata">

**Author:** ![rajeshjamariya16](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@rajeshjamariya16](https://forum.dynamobim.com/u/rajeshjamariya16)\
**Post date:** [January 7, 2025, 7:17am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/6 "2025-01-07T07:17:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [January 7, 2025, 7:25am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/7 "2025-01-07T07:25:33Z")

</div>

> [@niels.van.hove](#):
>
> i sorted the Ø, length and shape

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

---

<div class="post-metadata">

**Author:** ![niels.van.hove](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@niels.van.hove](https://forum.dynamobim.com/u/niels.van.hove)\
**Post date:** [January 7, 2025, 7:30am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/8 "2025-01-07T07:30:27Z")

</div>

yes thats correct!

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

---

<div class="post-metadata">

**Author:** ![niels.van.hove](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@niels.van.hove](https://forum.dynamobim.com/u/niels.van.hove)\
**Post date:** [January 7, 2025, 7:31am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/9 "2025-01-07T07:31:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [January 7, 2025, 7:59am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/10 "2025-01-07T07:59:52Z")

</div>

Got ya. Last question. I see all that …

> [@niels.van.hove](#):
>
> Ø, length and shape

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

---

<div class="post-metadata">

**Author:** ![niels.van.hove](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@niels.van.hove](https://forum.dynamobim.com/u/niels.van.hove)\
**Post date:** [January 7, 2025, 8:09am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/11 "2025-01-07T08:09:08Z")

</div>

[https://we.tl/t-uaY10QDJ7x](https://we.tl/t-uaY10QDJ7x?utm_campaign=TRN_TDL_05&utm_source=sendgrid&utm_medium=email&trk=TRN_TDL_05)

heres my rvt file (revit 2024) i use

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [January 7, 2025, 8:21am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/12 "2025-01-07T08:21:08Z")

</div>

Thats helpfull.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/9/e92d52d4667916a340aa1ae937a644d843e8090b.png)

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)?

---

<div class="post-metadata">

**Author:** ![niels.van.hove](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@niels.van.hove](https://forum.dynamobim.com/u/niels.van.hove)\
**Post date:** [January 7, 2025, 8:38am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/13 "2025-01-07T08:38:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [January 7, 2025, 8:47am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/14 "2025-01-07T08:47:31Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/6/962ef42d95a3a5bcfcc1b8d03bd278f84e51c1fb.png)

To

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/2/e2c7dfcfbf489e8b0157ce60630735bb0bc2dc43.png)

?

I used _Comments_ for my test. Could be _Mark_ as well.

---

<div class="post-metadata">

**Author:** ![rajeshjamariya16](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@rajeshjamariya16](https://forum.dynamobim.com/u/rajeshjamariya16)\
**Post date:** [January 7, 2025, 8:51am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/15 "2025-01-07T08:51:45Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/7/873935c708e06b8337e5bf95c79491bd9c5c4298.png)  
👉 I worked on the same script when I started learning dynamo.  
👉 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.  
👉 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.  
👉 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](https://forum.dynamobim.com/uploads/short-url/bfEoC0bhrCRqsqOimZl8Yfl9SEW.dyn) (51.5 KB)

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [January 7, 2025, 8:55am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/16 "2025-01-07T08:55:58Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/4/44eb821c04b1f7949b8265ea69f8abc45fa59811.png)

[TEST.dyn](https://forum.dynamobim.com/uploads/short-url/bvvyW5RjaFPVRR48oGaztTP7VFm.dyn) (26.6 KB)

---

<div class="post-metadata">

**Author:** ![rajeshjamariya16](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@rajeshjamariya16](https://forum.dynamobim.com/u/rajeshjamariya16)\
**Post date:** [January 7, 2025, 8:57am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/17 "2025-01-07T08:57:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rajeshjamariya16](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@rajeshjamariya16](https://forum.dynamobim.com/u/rajeshjamariya16)\
**Post date:** [January 7, 2025, 9:10am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/18 "2025-01-07T09:10:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![niels.van.hove](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@niels.van.hove](https://forum.dynamobim.com/u/niels.van.hove)\
**Post date:** [January 7, 2025, 9:11am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/19 "2025-01-07T09:11:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![niels.van.hove](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@niels.van.hove](https://forum.dynamobim.com/u/niels.van.hove)\
**Post date:** [January 8, 2025, 9:59am UTC](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023/20 "2025-01-08T09:59:39Z")

</div>

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](https://forum.dynamobim.com/uploads/short-url/fwr3u0ARyv8WF97XjHKF6oGDeWT.dyn) (131.6 KB)

[Next page](https://forum.dynamobim.com/t/numbering-rebar-marks-finding-duplicates/107023.md?page=2)
