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.
Automated part numbering
-
- Posts: 19
- Joined: Wed Feb 01, 2023 5:10 pm
- x 1
Re: Automated part numbering
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.
-
- Posts: 19
- Joined: Wed Feb 01, 2023 5:10 pm
- x 1
Re: Automated part numbering
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.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.
- AlexLachance
- Posts: 2226
- Joined: Thu Mar 11, 2021 8:14 am
- Location: Quebec
- x 2419
- x 2061
Re: Automated part numbering
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.
Re: Automated part numbering
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)
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
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
Re: Automated part numbering
Check the macro by @artem here
Deepak Gupta
SOLIDWORKS Consultant/Blogger
SOLIDWORKS Consultant/Blogger
-
- Posts: 19
- Joined: Wed Feb 01, 2023 5:10 pm
- x 1
Re: Automated part numbering
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