Macro: Retrieve the value of the last index

Hello

I develop a macro that saves the configurations of my parts and the different sheets, I would like to add the index in the file name.

Does there be an SW variable for this or a method?

1 Like

Hello

You would have to share a file if you want more help.

Cdlt

Without EPDM, you can retrieve  the custom properties of revision and n of part for example

See link below that may help you

https://www.lynkoa.com/forum/3d/macro-de-renseignement-de-proprietes

 

 

Cdlt 

Yannick

Hello

I have a macro to make a PDF, in which I put the value of the custom property "Revision". If this part can help....

 

Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim lErrors As Long
Dim lWarnings As Long

Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
 
PathName = UCase(swModel.GetPathName)
FilePath = Left(PathName, InStrRev(PathName, "\"))
FileTyp = swModel.GetType
 
Select Case FileTyp
    Case swDocDRAWING
        swModel.Extension.SaveAs FilePath & GetFilename(swModel.GetPathName) & "-" & swModel.CustomInfo2("", "Review") & ".pdf", swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, lErrors, lWarnings
End Select
 
End Sub

Function GetFilename(strPath As String) As String
    Dim strTemp As String
    strTemp = Mid$(strPath, InStrRev(strPath, "\") + 1)
    GetFilename = Left$(strTemp, InStrRev(strTemp, ".") - 1)
End Function

Thank you I look at this

1 Like

Thank you

Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim lastInd As String

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

lastInd = swModel.CustomInfo2("", "Revision")

MsgBox lastInd

End Sub

1 Like