hexagon logo

Automated Save-As

Whipped this up, when executed the user are prompted to enter a serial that is used to save the partprogram (to a new copy). Might come in handy for those running serial checks and want to keep the results for each part in it's own partprogram...

The serial is added to the partprogram filename:

Let's say that the partprogram name is 'Heatshield_1' and when entering the serial as 'number 1' the partprogram is saved as 'Heatshield_1_number 1.prg'.

REMOVED
Parents
  • Here is a change I made to VPT.SE's code.
    I took out the input for serial number and have pc-dmis save the file using the current time and date as an extension to the file name.

    Good luck.

    ' Displays an inputbox telling the user To enter a serialnumber
    ' 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
    '
    Sub Main()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram

    ' my added code
    HR = HOUR(NOW)
    MN = MINUTE(NOW)
    SEC = SECOND(NOW)
    MON = MONTH(NOW)
    DY = DAY(NOW)
    YR = YEAR(NOW)
    'my added code

    'my change In VPT.SE's code
    newname = PCDPartProgram.Path & PCDPartProgram.PartName & "_" & HR & "_" & MN & "_" & SEC & "_" & MON & "_" & DY & "_" & YR & "_" & ".PRG"
    'my change In code

    retval = PCDPartProgram.SaveAs(newname)

    ' Cleanup
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub



    This copies the program named SAMPLE PROGRAM.PRG

    and adds the extensions _HR_MIN_SEC_MON_DY_YR_

    SAMPLE PROGRAM.PRG now becomes

    SAMPLE PROGRAM_10_14_37_1_20_2011_.PRG
Reply
  • Here is a change I made to VPT.SE's code.
    I took out the input for serial number and have pc-dmis save the file using the current time and date as an extension to the file name.

    Good luck.

    ' Displays an inputbox telling the user To enter a serialnumber
    ' 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
    '
    Sub Main()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram

    ' my added code
    HR = HOUR(NOW)
    MN = MINUTE(NOW)
    SEC = SECOND(NOW)
    MON = MONTH(NOW)
    DY = DAY(NOW)
    YR = YEAR(NOW)
    'my added code

    'my change In VPT.SE's code
    newname = PCDPartProgram.Path & PCDPartProgram.PartName & "_" & HR & "_" & MN & "_" & SEC & "_" & MON & "_" & DY & "_" & YR & "_" & ".PRG"
    'my change In code

    retval = PCDPartProgram.SaveAs(newname)

    ' Cleanup
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub



    This copies the program named SAMPLE PROGRAM.PRG

    and adds the extensions _HR_MIN_SEC_MON_DY_YR_

    SAMPLE PROGRAM.PRG now becomes

    SAMPLE PROGRAM_10_14_37_1_20_2011_.PRG
Children
No Data