5 Replies Latest reply on Apr 19, 2017 2:48 PM by Hrishikesh Shirsikar

    Using the SOLIDWORKS® Enterprise PDM Convert Task, is it possible to use a variable value from the data card of the source file in the output FOLDER name?

    Hrishikesh Shirsikar

      Hello all, I know there is KB article for this S-061104. But when I made changes to the default script settings as suggested by KB article it is not working. So please suggest me correct changes so that I will be able to execute a task. 

        • Re: Using the SOLIDWORKS® Enterprise PDM Convert Task, is it possible to use a variable value from the data card of the source file in the output FOLDER name?
          Jason Koonce

          Yes it is possible.  Can you give an example of what you are wanting to do?  I may be able to help, I just recently accomplished this as well.

          • Re: Using the SOLIDWORKS® Enterprise PDM Convert Task, is it possible to use a variable value from the data card of the source file in the output FOLDER name?
            Jason Koonce

            To give an example this is what I as able to do, here is part of the code I was able to use.  I am no programmer so it might be sloppy but it works.

             

                'GET VAULT INTERFACE

                Call LoginToVault

                'GET VARIABLE VALUES

                Dim VarValue

             

                VarValue = GetVariableValue(docFileName, "Production Part Number", "@")

                   

                ' Determine type of SolidWorks file based on file extension

                If LCase(Right(docFileName, 7)) = ".sldprt" Or LCase(Right(docFileName, 4)) = ".prt" Then

                    docType = swDocPART

                ElseIf LCase(Right(docFileName, 7)) = ".sldasm" Or LCase(Right(docFileName, 4)) = ".asm" Then

                    docType = swDocASSEMBLY

                ElseIf LCase(Right(docFileName, 7)) = ".slddrw" Or LCase(Right(docFileName, 4)) = ".drw" Then

                    docType = swDocDRAWING

                Else

                    docType = swDocNONE

                     If bIsSupportedExtension(Mid(docFileName, InStrRev(docFileName, ".") + 1)) = False Then

                         Log "The file extension '" & Mid(docFileName, InStrRev(docFileName, ".") + 1) & "' is not supported."

                         Exit Sub

                     End If       

                End If

                   

                ' Open document

                If docType = swDocNONE Then

                    Set swModel = swApp.LoadFile4(docFileName, "", Nothing, errors)

                    docType = swModel.GetType

                Else 

                    Set swDocSpecification = swApp.GetOpenDocSpec(docFileName)

                    swDocSpecification.DocumentType = docType

                    swDocSpecification.ReadOnly = True

                    swDocSpecification.Silent = True

                    swDocSpecification.ConfigurationName = ""

                    swDocSpecification.DisplayState = ""

                    swDocSpecification.IgnoreHiddenComponents = True 'SPR 682792, 538578, 651998

                    Set swModel = swApp.OpenDoc7(swDocSpecification)

                    errors = swDocSpecification.Error

             

             

                   ' Set swModel = swApp.OpenDoc6(docFileName, docType, swOpenDocOptions_Silent Or swOpenDocOptions_ReadOnly, "", errors, warnings)

                End If

               

                If errors = swFutureVersion Then

                    Log "Document '" & docFileName & "' is future version."

                    Exit Sub

                End If

             

             

                ' Load failed?

                If swModel Is Nothing Then

                    Log "Method call ModelDoc2::OpenDoc7 for document '" & docFileName & "' failed. Error code " & errors & " returned."

                    Exit Sub

                End If

               

                If Val(Left(swApp.RevisionNumber, 2)) >= 18 Then

                  swApp.Frame.KeepInVisible = True

                End If

             

             

                swApp.ActivateDoc2 docFileName, True, errors

                modelPath = swModel.GetPathName()

                If modelPath = "" Then

                  modelPath = docFileName

                End If

                modelFileName = Mid(modelPath, InStrRev(modelPath, "\") + 1)

                modelFileName = Left(modelFileName, InStrRev(modelFileName, ".") - 1)

                modelExtension = Mid(modelPath, InStrRev(modelPath, ".") + 1)

             

             

                ' Build destination filenames

                convFileName = "[OutputPath]"

                ' MsgBox convFileName

               

                Dim convFileName2 As String

                convFileName2 = "[OutputPath2]"

                Dim convFilePath2 As String

                Dim convFileNameTemp2 As String

               

                Dim bSecondOutput As Boolean

                bSecondOutput = False

                If (Len(convFileName2) > 0) Then

                    bSecondOutput = True

                End If

                   

                ext = GetExtension(docType, "[FileFormat]")

               

                convFileName = Replace(convFileName, "<Filename>", modelFileName)

                convFileName = Replace(convFileName, "<Extension>", modelExtension)

                convFileName = Replace(convFileName, "<VariableValue>", VarValue)