# “Dynamo Script to Automatically Renumber Text Notes Starting with Prefix (e.g., Z2\_L0\_) in Revit”

**URL:** <https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [November 27, 2025, 5:19am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212 "2025-11-27T05:19:21Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobiyey908](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@tobiyey908](https://forum.dynamobim.com/u/tobiyey908)\
**Post date:** [November 27, 2025, 5:19am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/1 "2025-11-27T05:19:21Z")

</div>

I have text notes in Revit that follow a pattern like **Z2\_L0\_69** , **Z2\_L0\_70** , etc.  
I need to automatically change or renumber the numbers **after the prefix (Z2\_L0\_)**.  
I want to know if there is a Dynamo script or automation method to:

- find all text notes with this prefix

- extract the number

- change or renumber it automatically

I have text notes in Revit that follow a pattern like **Z2\_L0\_69** , **Z2\_L0\_70** , etc.  
I need to automatically change or renumber the numbers **after the prefix (Z2\_L0\_)**.  
I want to know if there is a Dynamo script or automation method to:

- find all text notes with this prefix

- extract the number

- change or renumber it automatically

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [November 27, 2025, 5:29am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/2 "2025-11-27T05:29:53Z")

</div>

unlikely that someone has done exactly what you want, but yes, I’d say it is possible.

Could be better to use keynotes not text

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [November 27, 2025, 5:30am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/3 "2025-11-27T05:30:20Z")

</div>

Hi Tobiyay, welcome 👋  
What have you tried so far?

You can collect all the text notes in a document

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/7/a75ad281c654f2bd83434e3771c6addd3f5447f0.png)

There are string nodes that can find, extract and modify the data as required  
You can save back to the notes

This would be an excellent first project for a new Dynamo user

Please take the time to read [How to get help on the Dynamo forums](https://forum.dynamobim.com/t/how-to-get-help-on-the-dynamo-forums/4677)

---

<div class="post-metadata">

**Author:** ![tobiyey908](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@tobiyey908](https://forum.dynamobim.com/u/tobiyey908)\
**Post date:** [November 27, 2025, 5:41am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/4 "2025-11-27T05:41:57Z")

</div>

**Thanks for the reply!**

You’re right — it might be a bit of an uncommon scenario.  
Regarding keynotes: I initially thought of using them, but in my project, the text notes are being used for specific labeling that can’t easily be replaced with keynotes. Still, I’ll consider keynotes for future projects or if the script approach doesn’t work.

Would you have any recommendations on how to approach this in Dynamo, or any sample scripts for renumbering elements or text in a batch process?

Thanks again!

---

<div class="post-metadata">

**Author:** ![tobiyey908](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@tobiyey908](https://forum.dynamobim.com/u/tobiyey908)\
**Post date:** [November 27, 2025, 5:43am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/5 "2025-11-27T05:43:44Z")

</div>

**Thanks for the help, Mike!**

I appreciate the advice and the welcome. So far, I’ve tried collecting the text notes using the `All Elements of Category` node, and I’ve used the `TextNote.Text` node to extract the text content. However, I’m having trouble incrementing or renumbering the numbers after the prefix (e.g., `Z2_L0_69` → `Z2_L0_70`).

Do you have any suggestions on how to easily implement the logic for incrementing the numbers? I understand string nodes can help, but I’m unsure of the best way to split and manipulate the numbers.

Additionally, if you know of any example scripts that would help me get started with this task, I’d really appreciate it!

Thanks again for your time!

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [November 27, 2025, 5:50am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/6 "2025-11-27T05:50:07Z")

</div>

I’d suggest sharing what you have done & make any questions specific to a node or problem- you’ll get better answers with better questions

Also play around with some of the string nodes e.g splitting a string at a character, at a specific position

e.g split the string at a delimiter character, get the first 2 characters etc

---

<div class="post-metadata">

**Author:** ![tobiyey908](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@tobiyey908](https://forum.dynamobim.com/u/tobiyey908)\
**Post date:** [November 27, 2025, 5:57am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/7 "2025-11-27T05:57:50Z")

</div>

![Screenshot 2025-11-27 112338](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/1/41f742af9442957f41d737e9bed7a3078f27ab62.png)

KINDLY HELP ME OUT !!! I AM NEW TO DYNAMO WHAT IS NEXT STEP

---

<div class="post-metadata">

**Author:** ![sovitek](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/sovitek/32/116237_2.png) [@sovitek](https://forum.dynamobim.com/u/sovitek)\
**Post date:** [November 27, 2025, 6:06am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/8 "2025-11-27T06:06:13Z")

</div>

Hi @tobiyey908 thats multiline text, try something here  
 ![Revit_xpcm5WdvGU](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/d/ad0458ba1e66e49b900e545a50fe3429753cddd4.gif)  
a fast example

---

<div class="post-metadata">

**Author:** ![tobiyey908](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@tobiyey908](https://forum.dynamobim.com/u/tobiyey908)\
**Post date:** [November 27, 2025, 6:15am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/9 "2025-11-27T06:15:59Z")

</div>

Thank you for the explanation! I Will give it a try and let you know if I have any further questions.

---

<div class="post-metadata">

**Author:** ![sovitek](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/sovitek/32/116237_2.png) [@sovitek](https://forum.dynamobim.com/u/sovitek)\
**Post date:** [November 27, 2025, 6:17am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/10 "2025-11-27T06:17:13Z")

</div>

yoy are wlecome 😉 and maybe trim white space node could help as well maybe depends

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 27, 2025, 10:00am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/11 "2025-11-27T10:00:23Z")

</div>

Some nodes which will help you out @tobiyey908 (in a somewhat sequential order from after your TextNote.Text

1. `String.StartsWith` to identify an text which starts with your prefix.
2. `List.FilterByBoolMask` to remove any text notes you don’t want to change. Be sure to use your text notes (from `All Elements of Category`), not the text itself (from `TextNote.Text`) as your list.
3. `TextNote.Text` to get the text from the notes after filtering.
4. `String.Split` to break each note into two parts at the “\_” character.
5. `List.LastItem` to get the ‘numbers’ which you’ll need to increment. Watch your lacing and list levels (you likely want `@L2`).
6. `String.ToNumber` to convert the text `"60"` to `60` (colors change from orange to blue).
7. `+` to add one to the value.
8. `+` again with an empty string to convert the numbers back to text.
9. `List.ReplaceItemAtIndex` to swap the last item in each sublist from the `String.Split` node with your incremented text.
10. `TextNote.SetText` (or something similar - as I can’t remember the exact name, but if you find ‘text note’ in your library you’ll be able to identify it quickly).

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 27, 2025, 10:33am UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/12 "2025-11-27T10:33:12Z")

</div>

Hi  
For the TextNote positioning, I used the Coord property of the TextNote class from the API (packages almost certainly exist for this aspect).  
Starting with a bounding box, if you have two numbers, you have a variation on X for the TextNote ordering.

 ![reponse forum 25_11_27_2025-11-27_11-30-23](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/7/8727cc82934b90d26c1d9fefc09ba21df5eb43c3.png)

```auto
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

ltextn=UnwrapElement(IN[0])

OUT = sorted(ltextn,key=lambda x:x.Coord.ToPoint().X)

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/b/0b89d5a3834ccab5783070720f9c1a6487e9ba63.png)

Regards, Christian Stan

---

<div class="post-metadata">

**Author:** ![tobiyey908](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@tobiyey908](https://forum.dynamobim.com/u/tobiyey908)\
**Post date:** [November 27, 2025, 2:18pm UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/13 "2025-11-27T14:18:13Z")

</div>

![Screenshot 2025-11-27 194339](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/5/f5a650c63e3c90f5ac8d329c1fd3196e0d6bfe75.png)

 ![Screenshot 2025-11-27 194400](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/2/f24ec0c271942702bf811c0fcccb30afd5d78037.png)

[Renumber Text Notes Starting with Prefix.dyn](https://forum.dynamobim.com/uploads/short-url/u1tQXEOEL8mgPqcQj1RYHYlsdpj.dyn) (45.6 KB)

"I tried running this script, but I’m getting several warnings. Could you please advise if anything needs to be modified or if there’s another approach I should try? I’ve attached the image and the .dyn file for your reference.

If there are any additional steps I need to follow, or if I should use a different node setup, kindly let me know. Your guidance will really help me move forward. Thank you in advance!"

---

<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:** [November 27, 2025, 2:55pm UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/14 "2025-11-27T14:55:16Z")

</div>

@tobiyey908 It helps if you post what the warnings says and pin the preview bubbles.

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 27, 2025, 3:04pm UTC](https://forum.dynamobim.com/t/dynamo-script-to-automatically-renumber-text-notes-starting-with-prefix-e-g-z2-l0-in-revit/113212/15 "2025-11-27T15:04:17Z")

</div>

You have errors with these incoming connections; poor connection.

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

Regards, Christian Stan

edit: Note: This is a comparison based on diameter.

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

Edit 2: Here’s Python for handling different diameter types

```auto
import sys

OUT =[sum([j.count(i) for i in [chr(248),chr(216),"x",chr(8960)]]) for j in IN[0]]

```

Regards, Christian Stan
