Macro to pick the first 5 characters of the file name

how to write a solidworks macro to pick the first 5 characters of the file name and assign it to a custom property

SolidworksApi/macros
Answers 1
AT
AT 2021-04-08 Best Answer

Below code would read 5 chars from the model title, where swModel is of type IModelDoc2 or any derived (i.e. IPartDoc, IAssemblyDoc, IDrawingDoc).

Dim val As String

val = Left(swModel.GetTitle(), 5)

Read the following article on how to assign the values to custom properties: SOLIDWORKS Custom Properties Automation