laitimes

Solidworks Symbol Separation Code (Four Spaces Separated)

author:54 weeks Xiaoxian

Dim swApp As Object

Dim Part As Object

Dim FL_N, XX_L As Variant

Dim F_name As String

Dim i As Integer

'——————————— make changes according to your needs————————————————————————————————————————

Public Const c = "" ' file name separation symbol

Public Const b = "Item Code Version Number/Model Name" 'Attribute Name--Corresponds to the name of the write file name separation

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

F_name = Part.GetPathName 'full path.'

F_name = Mid(F_name, InStrRev(F_name, "\") + 1, Len(F_name) - InStrRev(F_name, "\") - 7) 'File name

FL_N = Split(F_name, c)

XX_L = Split(b, " ")

If UBound(FL_N) > UBound(XX_L) Then MsgBox "Warning: The attribute name is not enough for the detached file name!" : End

For i = 0 To UBound(FL_N)

Part.DeleteCustomInfo2 "", XX_L(i)

Part.AddCustomInfo3 "", XX_L(i), swCustomInfoText, FL_N(i) 'Separate each segment name is written

Next i

End Sub

Read on