hexagon logo

Saving PCDMIS file at end of program

Can anyone give me a code example for saving the entire PCDMIS file and CAD file in a certain location at the end of the program?

Thanks.
Parents
  • This method uses several arguments passed over from PC-DMIS to concatenate the path and file name and then saves the program as that path/file name. So this is a push method where the data is pushed over to the script when the script is called. You can also use a pull method were you use the ".GetVariableValue" method to pull the value from a specific variable in the PC-DMIS program. An example of this type of code follows after the main script.


    Sub Main (PN As String, OP As String, SN As String, RPTTIME As String, RPTDATE As String, PRG As String, PRG_TYPE As String)
    
    Dim App As Object
    Dim Part As Object
    Dim Cmds As Object
    Dim Cmd As Object
    
    ' Initialize PC-DMIS
    Set App = CreateObject("PCDLRN.Application")
        If App Is Nothing Then
            MsgBox "PC-DMIS initialization error!",48, "Error!"
            Exit Sub
        Else
            Set Part = App.ActivePartProgram
            If Part Is Nothing Then
                MsgBox "Part Program not opened!", 48, "Error!"
                Exit Sub
            Else
                Set Cmds = Part.Commands
                If Cmds Is Nothing Then
                    MsgBox "Pointer to commands not valid!", 48, "Error!"
                    Exit Sub
                End If
            End If
        End If
    
    
    Dim CrntName As String
    Dim NewName As String
    
    CrntName = Part.FullName
    'MsgBox(CrntName)
    
    Newname = PRG & PN & "\RESULTS\" & OP & "\" & PN & "_" & OP & "_" & PRG_TYPE & "_" & SN & "_" & RPTDATE & "_" & RPTTIME & ".PRG"
    'MsgBox(Newname)
    
    Dim Retval As Boolean
    retval = Part.SaveAs(newname)  
    
    
    ' Cleanup
    Set Cmd = Nothing
    Set Cmds = Nothing
    Set Part = Nothing
    Set App = Nothing
    End Sub



    Set Part_Num = Part.GetVariableValue ("PN")
    PN = Part_Num.doublevalue
    
Reply
  • This method uses several arguments passed over from PC-DMIS to concatenate the path and file name and then saves the program as that path/file name. So this is a push method where the data is pushed over to the script when the script is called. You can also use a pull method were you use the ".GetVariableValue" method to pull the value from a specific variable in the PC-DMIS program. An example of this type of code follows after the main script.


    Sub Main (PN As String, OP As String, SN As String, RPTTIME As String, RPTDATE As String, PRG As String, PRG_TYPE As String)
    
    Dim App As Object
    Dim Part As Object
    Dim Cmds As Object
    Dim Cmd As Object
    
    ' Initialize PC-DMIS
    Set App = CreateObject("PCDLRN.Application")
        If App Is Nothing Then
            MsgBox "PC-DMIS initialization error!",48, "Error!"
            Exit Sub
        Else
            Set Part = App.ActivePartProgram
            If Part Is Nothing Then
                MsgBox "Part Program not opened!", 48, "Error!"
                Exit Sub
            Else
                Set Cmds = Part.Commands
                If Cmds Is Nothing Then
                    MsgBox "Pointer to commands not valid!", 48, "Error!"
                    Exit Sub
                End If
            End If
        End If
    
    
    Dim CrntName As String
    Dim NewName As String
    
    CrntName = Part.FullName
    'MsgBox(CrntName)
    
    Newname = PRG & PN & "\RESULTS\" & OP & "\" & PN & "_" & OP & "_" & PRG_TYPE & "_" & SN & "_" & RPTDATE & "_" & RPTTIME & ".PRG"
    'MsgBox(Newname)
    
    Dim Retval As Boolean
    retval = Part.SaveAs(newname)  
    
    
    ' Cleanup
    Set Cmd = Nothing
    Set Cmds = Nothing
    Set Part = Nothing
    Set App = Nothing
    End Sub



    Set Part_Num = Part.GetVariableValue ("PN")
    PN = Part_Num.doublevalue
    
Children
No Data