3 Replies Latest reply on Mar 13, 2015 11:34 AM by Chris Champions

    Extract a custom property from ref. files

    Chris Champions

      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 error code 5  swCustPropMgr.Get4 "Revision", True, Empty, strValOut

       

      For 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