Here's my scenario. In my PDM data card for SolidWorks files I have a variable named "Part Number" and it's default value is "File Name without extension"
We have some part numbers that have a slash in them. for example: 1_4-28
obviously windows doesn't allow a slash in a part number, hence the underscore.
Is it possible to do a replace in a string in a PDM variable? Basically want to have another variable that references the "Part Number" variable and replaces the underscore with a slash to give you: 1/4-28.
original variable:
"Part Number" = 1_4-28
new variable:
"Part Number Replace" = 1/4-28
Thanks - Eric
'Replace CustomProps _ with /
'Made by Niels Raahauge
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim textexp As String
Dim evalval As String
Dim n_evalval As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swCustPropMgr = swModel.Extension.CustomPropertyManager("")
swCustPropMgr.Get2 "part number", textexp, evalval
Debug.Print "part number" & " = " & evalval
n_evalval = Replace(evalval, "_", "/")
Debug.Print "part number" & " = " & n_evalval
swCustPropMgr.Set2 "part number", n_evalval
End Sub