Automated part numbering

Library for macros
chancegarrison
Posts: 19
Joined: Wed Feb 01, 2023 5:10 pm
Answers: 0
x 1

Automated part numbering

Unread post by chancegarrison »

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.
tate876
Posts: 7
Joined: Thu Nov 07, 2024 10:15 am
Answers: 0
x 1

Re: Automated part numbering

Unread post by tate876 »

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.
chancegarrison
Posts: 19
Joined: Wed Feb 01, 2023 5:10 pm
Answers: 0
x 1

Re: Automated part numbering

Unread post by chancegarrison »

tate876 wrote: Tue Nov 12, 2024 11:20 am 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.
User avatar
AlexLachance
Posts: 2226
Joined: Thu Mar 11, 2021 8:14 am
Answers: 17
Location: Quebec
x 2419
x 2061

Re: Automated part numbering

Unread post by AlexLachance »

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.
User avatar
SPerman
Posts: 2080
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 14
x 2256
x 1902
Contact:

Re: Automated part numbering

Unread post by SPerman »

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)
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
User avatar
gupta9665
Posts: 420
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 438
x 459

Re: Automated part numbering

Unread post by gupta9665 »

Check the macro by @artem here
Deepak Gupta
SOLIDWORKS Consultant/Blogger
chancegarrison
Posts: 19
Joined: Wed Feb 01, 2023 5:10 pm
Answers: 0
x 1

Re: Automated part numbering

Unread post by chancegarrison »

gupta9665 wrote: Wed Nov 13, 2024 12:59 am Check the macro by @artem here
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
image.png
Post Reply