I followed the directions for the example you provided, and it worked as described, but I would need to break it down, pull it apart and rebuild differently to build the solution I'm looking for.
1. I shouldn't have to choose the vault, as it would be whatever vault the target file(s) is in.
2. Instead of just displaying an "FYI" list of the existing serial number options in the vault, I would want to select them from a combo box.
3. In addition to add the new serial number to the Part Number variable, I would also want to rename the file.
If you want to spend the time to learn the API, you need to login, create the utility, list the serial number names, select which serial number scheme to use, and use the AllocSerNoValue to get the next value. If you are only wanting to see the next value, then after calling the AllocSerNoValue method, issue the
Here's how to list the next serial number
Dim serialNbrValue As IEdmSerNoValue serialNbrValue = serialNbrs.AllocSerNoValue("<serial number scheme from admin tool goes here>", Me.Handle.ToInt32) Dim serialNbrValueValue = serialNbrValue.Value MessageBox.Show("Next Part Number is " + serialNbrValueValue.ToString) Dim serialNbrValueValue = serialNbrValue.Rollback 'After displaying the value then call serialNbrValue.Rollback to return the pulled number to the counter.
Hope this helps!
Thanks for the advise. My goal is for this to be executed while the part is open in SolidWorks. This will replace the Auto Generate Serial number on Save/Save as, giving the user a more "on demand" solution AND the flexibility of selecting which number scheme they want.
New File or Existing file (not checked out) is open and active in SW.
User executes API
User selects a Naming Scheme
Once scheme is selected, the next number in that scheme is displayed.
User clicks OK to execute.
Save as dialog appears to allow user to choose file location.
File is Saved as the new number.
That's challenging! I love it.
I have some code that will do both but I haven't married them together in a SW API macro. I am initially thinking it would be better to run this as a PDM add-in then again, a VBA macro may be all that's needed. Hmmmm.....