# Automated part numbering

**URL:** <https://forum.cadmunity.com/t/automated-part-numbering/3317>\
**Category:** Macro Library\
**Created:** [November 12, 2024, 2:03pm UTC](https://forum.cadmunity.com/t/automated-part-numbering/3317 "2024-11-12T14:03:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chancegarrison](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/c/df705f/32.png) [@chancegarrison](https://forum.cadmunity.com/u/chancegarrison)\
**Post date:** [November 12, 2024, 2:03pm UTC](https://forum.cadmunity.com/t/automated-part-numbering/3317/1 "2024-11-12T14:03:16Z")

</div>

Hello friends,  
Does anyone know of a macro that automates part numbering?  
It would be awesome to have a macro that selects the next available part number that you could input on the fly that also stores the previous input until changed.

For example, I make a new part for project XYZ-000. There are already parts for XYZ-000 that are named XYZ-000-001, XYZ-000-002.  
When I click save, if a prompt opened that I could input “XYZ-000-” and the part was automatically named XYZ-000-003.

---

<div class="post-metadata">

**Author:** ![tate876](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/t/e5b9ba/32.png) [@tate876](https://forum.cadmunity.com/u/tate876)\
**Post date:** [November 12, 2024, 4:20pm UTC](https://forum.cadmunity.com/t/automated-part-numbering/3317/2 "2024-11-12T16:20:31Z")

</div>

You could set up a simple macro that checks the last number used in the format and adds 1 to it. For example, it could search for the highest number in your project (like XYZ-000-002), then prompt you for the prefix (XYZ-000-) and auto-generate the next number (XYZ-000-003). If you’re using Excel or a similar program, it might be as easy as a simple formula, or if you’re in a more coding-heavy environment, a quick script could do the job.

---

<div class="post-metadata">

**Author:** ![chancegarrison](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/c/df705f/32.png) [@chancegarrison](https://forum.cadmunity.com/u/chancegarrison)\
**Post date:** [November 12, 2024, 4:59pm UTC](https://forum.cadmunity.com/t/automated-part-numbering/3317/3 "2024-11-12T16:59:28Z")

</div>

> [@](#):
>
> You could set up a simple macro that checks the last number used in the format and adds 1 to it. For example, it could search for the highest number in your project (like XYZ-000-002), then prompt you for the prefix (XYZ-000-) and auto-generate the next number (XYZ-000-003). If you’re using Excel or a similar program, it might be as easy as a simple formula, or if you’re in a more coding-heavy environment, a quick script could do the job.

Currently I just use save, then it opens the file directory where my files are saved and I scroll down until I see the last used number.

---

<div class="post-metadata">

**Author:** ![AlexLachance](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/alexlachance/32/25_2.png) [@AlexLachance](https://forum.cadmunity.com/u/AlexLachance)\
**Post date:** [November 12, 2024, 5:01pm UTC](https://forum.cadmunity.com/t/automated-part-numbering/3317/4 "2024-11-12T17:01:04Z")

</div>

We use CustomTools to do this, it has a SQL Database built for this purpose, though I’m sure if you’re a one man team, something simple like tate876 said would most likely be much more viable.

---

<div class="post-metadata">

**Author:** ![SPerman](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/sperman/32/59_2.png) [@SPerman](https://forum.cadmunity.com/u/SPerman)\
**Post date:** [November 12, 2024, 7:57pm UTC](https://forum.cadmunity.com/t/automated-part-numbering/3317/5 "2024-11-12T19:57:23Z")

</div>

You might be able to take this and modify it. It says it generates a random part number but you might be able to change it to generate a serialized number.

[Revision control app macro (release)](https://www.cadforum.net/viewtopic.php?t=1823)

---

<div class="post-metadata">

**Author:** ![gupta9665](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/gupta9665/32/6304_2.png) [@gupta9665](https://forum.cadmunity.com/u/gupta9665)\
**Post date:** [November 13, 2024, 5:59am UTC](https://forum.cadmunity.com/t/automated-part-numbering/3317/6 "2024-11-13T05:59:22Z")

</div>

Check the macro by ~~[mention]~~artem[/mention] here [https://www.youtube.com/watch?v=tgRB8YtB4v4](https://www.youtube.com/watch?v=tgRB8YtB4v4)

---

<div class="post-metadata">

**Author:** ![chancegarrison](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/c/df705f/32.png) [@chancegarrison](https://forum.cadmunity.com/u/chancegarrison)\
**Post date:** [November 14, 2024, 8:10pm UTC](https://forum.cadmunity.com/t/automated-part-numbering/3317/7 "2024-11-14T20:10:38Z")

</div>

~~[quote=gupta9665 post\_id=37760 time=1731477562 user\_id=98]~~  
Check the macro by @artem here [https://www.youtube.com/watch?v=tgRB8YtB4v4](https://www.youtube.com/watch?v=tgRB8YtB4v4)  
[/quote]  
Thanks Deepak!  
  
Would it be possible to add a prompt to pop up when running the macro that allowed the user to input these values? That would be exactly what im looking for. The user would click save, be prompted to select a folder, then enter the base name to be searched within the folder (for example: PRT-001 is already used) so user enters PRT- and the macro automatically knows to save the new part as PRT-002.  
  
Const NMB\_SRC\_FILE\_PATH As String = “D:\prt.txt” 'path to store the current part index  
  
Const NMB\_FORMAT As String = “000” 'padding for the number, e.g. 001, 002, instead of 1, 2  
  
Const BASE\_NAME As String = “PRT-” 'Base prefix for file naming  
~~[attachment=0]~~image.png[/attachment]
