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
  • Here is my version where it adds the date and the serialization entered and then restores the file name.

    ' Displays an inputbox telling the user To enter a serial number
    ' Or other information that will be concatenated To the partprogram
    ' Name (partname) And saved In the current partprogram folder.
    '
    ' ORIGINAL CODE by vpt.se 2010
    '
    ' Modified by Doug To just concatenate the date And time
    ' And To take the serialization number from ASSIGN/SRN="xxx" in the program And Input it into this one
    '
    Sub Main()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    
    Dim setCrntName As String 
    Set Serial = PCDPartProgram.GetVariableValue ("SRN")
    Dim SerialNo As String
    
    SerialNo = Serial.StringValue
    
    
    ' my added code
    HR = HOUR(NOW)
    MN = MINUTE(NOW)
    SEC = SECOND(NOW)
    MON = MONTH(NOW)
    DY = DAY(NOW)
    YR = YEAR(NOW)
    'my added code
    
    'added Mar 13, 2014 testing creating directory Name from date.
    
    Select Case MON
        Case "1"
           MonthName="JAN"
        Case "2"
           MonthName ="FEB"
        Case "3"
           MonthName="MAR"
        Case "4"
           MonthName="APR"
        Case "5"
          MonthName="MAY"
        Case "6"
          MonthName="JUN"
        Case "7"
          MonthName="JUL"
        Case "8"
          MonthName="AUG"
        Case "9"
          MonthName="SEP"
        Case "10"
          MonthName="OCT"
        Case "11"
          MonthName="NOV"
        Case "12"
          MonthName="DEC"
    End Select
    
    
    ' MsgBox DY & MonthName & YR
    
    setCrntName = PCDPartProgram.FullName
    
    'my change In VPT.SE's code
    newname = PCDPartProgram.Path & "RESULTS\" &  PCDPartProgram.PartName & " - " & DY & MonthName & YR & " - " & SerialNo & ".PRG"
    'my change In code
    
    retval = PCDPartProgram.SaveAs(newname)
    retval = PCDPartProgram.SaveAs(setCrntName)
    
    ' Cleanup
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub
    
Reply
  • Here is my version where it adds the date and the serialization entered and then restores the file name.

    ' Displays an inputbox telling the user To enter a serial number
    ' Or other information that will be concatenated To the partprogram
    ' Name (partname) And saved In the current partprogram folder.
    '
    ' ORIGINAL CODE by vpt.se 2010
    '
    ' Modified by Doug To just concatenate the date And time
    ' And To take the serialization number from ASSIGN/SRN="xxx" in the program And Input it into this one
    '
    Sub Main()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    
    Dim setCrntName As String 
    Set Serial = PCDPartProgram.GetVariableValue ("SRN")
    Dim SerialNo As String
    
    SerialNo = Serial.StringValue
    
    
    ' my added code
    HR = HOUR(NOW)
    MN = MINUTE(NOW)
    SEC = SECOND(NOW)
    MON = MONTH(NOW)
    DY = DAY(NOW)
    YR = YEAR(NOW)
    'my added code
    
    'added Mar 13, 2014 testing creating directory Name from date.
    
    Select Case MON
        Case "1"
           MonthName="JAN"
        Case "2"
           MonthName ="FEB"
        Case "3"
           MonthName="MAR"
        Case "4"
           MonthName="APR"
        Case "5"
          MonthName="MAY"
        Case "6"
          MonthName="JUN"
        Case "7"
          MonthName="JUL"
        Case "8"
          MonthName="AUG"
        Case "9"
          MonthName="SEP"
        Case "10"
          MonthName="OCT"
        Case "11"
          MonthName="NOV"
        Case "12"
          MonthName="DEC"
    End Select
    
    
    ' MsgBox DY & MonthName & YR
    
    setCrntName = PCDPartProgram.FullName
    
    'my change In VPT.SE's code
    newname = PCDPartProgram.Path & "RESULTS\" &  PCDPartProgram.PartName & " - " & DY & MonthName & YR & " - " & SerialNo & ".PRG"
    'my change In code
    
    retval = PCDPartProgram.SaveAs(newname)
    retval = PCDPartProgram.SaveAs(setCrntName)
    
    ' Cleanup
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub
    
Children
No Data