I used this loop to PackNGo all models and the associated files (dwg) in an assembly file and it works ok
One problem: each time I run this code, I missed (return empty) at least 1 to few revisions extracted from the line swCustPropMgr.Get4 "Revision", True, Empty, strValOut
SolidworksApi macrosFor i = 0 To (PGDocCount - 1)
Set swCompModel = swApp.GetOpenDocumentByName(pgFileNames(i))
If Not swCompModel Is Nothing Then
Set swCustPropMgr = swCompModel.Extension.CustomPropertyManager(Empty)
swCustPropMgr.Get4 "Revision", True, Empty, strValOut 'Get the custom property value of Revision
Else 'if virtual component
strValOut = Empty
End If
' Determine type of SolidWorks file based on file extension
myFileName = GetFilenameFromPath(pgFileNames(i)) 'Strip the path
If InStr(LCase(myFileName), "sldprt") > 0 Then '
myFileName = Left(myFileName, InStrRev(myFileName, ".") - 1) & "_" & Left(strValOut, 1) & ".sldprt"
ElseIf InStr(LCase(myFileName), "sldasm") > 0 Then
myFileName = Left(myFileName, InStrRev(myFileName, ".") - 1) & "_" & Left(strValOut, 1) & ".sldasm"
ElseIf InStr(LCase(myFileName), "slddrw") > 0 Then
myFileName = Left(myFileName, InStrRev(myFileName, ".") - 1) & "_" & Left(strValOut, 1) & ".slddrw"
Else
' Only packing up SolidWorks files
Exit Sub
End If
pgSetFileNames(i) = myPath & myFileName
Debug.Print i & ". " & pgSetFileNames(i)
Next i
