SOLIDWORKS Enterprise PDM number assigner
SolidWorks’ virtual components are so, so sweet. The fact that SOLIDWORKS Enterprise PDM supports them adds just a bit more butter on top of the piece of toast. …but…what if you need to assign a virtual component a part number before you save it out as its own file? You cannot use SOLIDWORKS Enterprise PDM’s serial number generator because you have no way to get the number nor tell the generator you manually assigned a number.
Here is a nice little SOLIDWORKS macro to get you started. It simply finds the next available serial number and returns it to the user in a message box. The user can use this assigned number in anyway he chooses.
[You’ll need to replace “Trains” with your vault name and “PartNumber” with the name of your serial number.]
'remember to add PDMWE Type Lib as a reference!
Dim objVault As IEdmVault8
Dim objSerNoGenerator As IEdmSerNoGen6
Set objVault = New EdmVault5
objVault.LoginAuto "Trains", 0 'use name of your vault
Set objSerNoGenerator = objVault
strNewNumber = objSerNoGenerator.GenerateSerNo(_
"PartNumber", 0, "", 0, 0, 0, 0)
MsgBox "The next avaliable part number is: " _
Set objSerNoGenerator = Nothing
Set objVault = Nothing
Anytime you need the next avaliable serial number this could be used. i.e. files added via Pack and Go, drag and drop…