We have this great macro to grab the part number from a longer part name. It looks like this:
-----------------------------------------------------
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.DeleteCustomInfo ("PrtDashNumber")
swModel.AddCustomInfo2 "PrtDashNumber", swCustomInfoText, Mid(swModel.GetTitle, 18, 4)
End Sub
--------------------------------------------------------
We use it with a library feature to engrave a part. However, for each different job we have to change the two blue values shown above.
The part number always appears after the first "-" dash in a part name. For example "XX15232_XX032-8888_XXXXXXXX XXXXXX_xxxx"
It is also feasible that we could set a standard that all part numbers will have four digits.
So, I am trying to make the macro grab the first four digits after the first occurrence of a "-".
It seems like this is doable and I have found a few things that are close but not quite right.
Any suggestions?
SolidworksApi macros