hexagon logo

Using script to create folder for prg and save part program

Been reading up on the script manual (PC-DMIS) 3.6 Basic Language Reference Manual) trying to figure out how to get the script to create a folder for the report, the .prg, and any other files associated with the program by serial number of the part.

For example:
PART#_DESCRIPTION_SERIAL#_DATE_TIME

The goal is to write a script contained in the .prg that, upon execution of the part program, will create a folder in a specified directory with the variable filename using the inputs from the part program and save the .prg with the same name.

How would I pass the information from the operator inputs of the part program into the script to make this happen?
Parents
  • I know this thread is a bit old, but I just wanted to let everyone know that I have finally got the issue figured out.

    Below is the code from the prg and the script:

    This is the program code for the variables I wanted to pull in to the script to create the filename. I wanted the script to be generic enough to be implemented on the majority of the programs that we have to save on future editing time.

    ASSIGN/VPART="blah_blah"
                ASSIGN/VREV="1"
                ASSIGN/VDESCRIPTION="CF34-10A_MILL_AND_MOLD"
                ASSIGN/VPROGRAMID="PI-0364"
                ASSIGN/VPROGRAMREV="A"
    FPTRHARD   =FILE/OPEN,D:\CMM_PROGRAMS\PC-DMIS_SUPPORT_FILES\THIS_MACHINES_GLOBAL_SETTINGS\HARDWARE.TXT,READ
    VLOCALHARDWARE=FILE/READLINE,FPTRHARD,{VHARDWARE}
                FILE/CLOSE,FPTRHARD,KEEP
    FPTRSOFT   =FILE/OPEN,D:\CMM_PROGRAMS\PC-DMIS_SUPPORT_FILES\THIS_MACHINES_GLOBAL_SETTINGS\SOFTWARE.TXT,READ
    VLOCALSOFTWARE=FILE/READLINE,FPTRSOFT,{VSOFTWARE}
                FILE/CLOSE,FPTRSOFT,KEEP
    CSERIALNUMBER =COMMENT/INPUT,NO,FULL SCREEN=NO,
                ENTER SERIAL NUMBER (15 CHARACTERS MAX)
                ASSIGN/VSERIALNUMBER=CSERIALNUMBER.INPUT
                IF/CSERIALNUMBER.INPUT == 0
                ASSIGN/VSERIALNUMBER=" "
                END_IF/
    CCMMOPERATOR =COMMENT/INPUT,NO,FULL SCREEN=NO,
                ENTER CMM OPERATOR ID
                ASSIGN/VCMMOPERATOR=CCMMOPERATOR.INPUT
                IF/CCMMOPERATOR.INPUT == 0
                ASSIGN/VCMMOPERATOR=" "
                END_IF/
    CCUSTOM    =COMMENT/INPUT,NO,FULL SCREEN=NO,
                ENTER TOOL
                ASSIGN/VCUSTOM=CCUSTOM.INPUT
                IF/CCUSTOM.INPUT == 0
                ASSIGN/VCUSTOM=" "
                END_IF/
    CREMARKS   =COMMENT/INPUT,NO,FULL SCREEN=NO,
                ENTER OPTIONAL REMARKS IF DESIRED (30 CHARACTERS MAX)
                ASSIGN/VREMARKS=CREMARKS.INPUT
                IF/CREMARKS.INPUT == 0
                ASSIGN/VREMARKS=" "
                END_IF/
                TRACEFIELD/NO_DISPLAY,LIMIT=43 ; Part : VPART
                TRACEFIELD/NO_DISPLAY,LIMIT=7 ; Rev : VREV
                TRACEFIELD/NO_DISPLAY,LIMIT=43 ; Description : VDESCRIPTION
                TRACEFIELD/NO_DISPLAY,LIMIT=16 ; Serial Number : VSERIALNUMBER
                TRACEFIELD/NO_DISPLAY,LIMIT=11 ; Operator : VCMMOPERATOR
                TRACEFIELD/NO_DISPLAY,LIMIT=16 ; Tool : VCUSTOM
                TRACEFIELD/NO_DISPLAY,LIMIT=30 ; Remarks : VREMARKS
                TRACEFIELD/NO_DISPLAY,LIMIT=11 ; Program ID : VPROGRAMID
                TRACEFIELD/NO_DISPLAY,LIMIT=22 ; Hardware : VHARDWARE
                TRACEFIELD/NO_DISPLAY,LIMIT=22 ; Software : VSOFTWARE
                ASSIGN/VDATE=SYSTEMDATE("dd''MMM''yyyy")
                ASSIGN/VTIME=SYSTEMTIME("hh''mm")


    And this is the script for the script call that is right below the VTIME line:

    Sub Main
    
    'Declares the File System Object And Instantiates it
    Dim  objFSO
    Set  objFSO = CreateObject("Scripting.FileSystemObject")
    
    'Declares PC-DMIS As the Active Program/Application
    Dim PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set Part = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    'Declares Variables from the prg As Objects
    
    Dim VPART As Object
    Dim VDESCRIPTION As Object
    Dim VSERIALNUMBER As Object
    Dim VDATE As Object
    Dim VTIME As Object
    Dim RESULTS As String
    
    
    'Pulls the variables from the prg
    
    Set  VPART = Part.GetVariableValue ("VPART")
    Set  VDESCRIPTION = Part.GetVariableValue ("VDESCRIPTION")
    Set VSERIALNUMBER = Part.GetVariableValue ("VSERIALNUMBER")
    Set VDATE = Part.GetVariableValue ("VDATE")
    Set  VTIME = Part.GetVariableValue ("VTIME")
    
    'Declares the Filepath, Folder, And the Filename As a String
    
    strPath = Part.Path     'Uses the prg path As the path For the folder
    
    
    'Sets the folder Name And the Path For the Folder
    strFolderName = VPART.StringValue & "_" & VDESCRIPTION.StringValue & "_" & VSERIALNUMBER.StringValue & "_" & VDATE.StringValue & "_" & VTIME.StringValue
    strFolder = strPath & "RESULTS\" & strFolderName
    
    'This command creates the folder
    Set objFolder = objFSO.CreateFolder(strFolder)
    
    End Sub


    Thanks everyone for all of the help.
Reply
  • I know this thread is a bit old, but I just wanted to let everyone know that I have finally got the issue figured out.

    Below is the code from the prg and the script:

    This is the program code for the variables I wanted to pull in to the script to create the filename. I wanted the script to be generic enough to be implemented on the majority of the programs that we have to save on future editing time.

    ASSIGN/VPART="blah_blah"
                ASSIGN/VREV="1"
                ASSIGN/VDESCRIPTION="CF34-10A_MILL_AND_MOLD"
                ASSIGN/VPROGRAMID="PI-0364"
                ASSIGN/VPROGRAMREV="A"
    FPTRHARD   =FILE/OPEN,D:\CMM_PROGRAMS\PC-DMIS_SUPPORT_FILES\THIS_MACHINES_GLOBAL_SETTINGS\HARDWARE.TXT,READ
    VLOCALHARDWARE=FILE/READLINE,FPTRHARD,{VHARDWARE}
                FILE/CLOSE,FPTRHARD,KEEP
    FPTRSOFT   =FILE/OPEN,D:\CMM_PROGRAMS\PC-DMIS_SUPPORT_FILES\THIS_MACHINES_GLOBAL_SETTINGS\SOFTWARE.TXT,READ
    VLOCALSOFTWARE=FILE/READLINE,FPTRSOFT,{VSOFTWARE}
                FILE/CLOSE,FPTRSOFT,KEEP
    CSERIALNUMBER =COMMENT/INPUT,NO,FULL SCREEN=NO,
                ENTER SERIAL NUMBER (15 CHARACTERS MAX)
                ASSIGN/VSERIALNUMBER=CSERIALNUMBER.INPUT
                IF/CSERIALNUMBER.INPUT == 0
                ASSIGN/VSERIALNUMBER=" "
                END_IF/
    CCMMOPERATOR =COMMENT/INPUT,NO,FULL SCREEN=NO,
                ENTER CMM OPERATOR ID
                ASSIGN/VCMMOPERATOR=CCMMOPERATOR.INPUT
                IF/CCMMOPERATOR.INPUT == 0
                ASSIGN/VCMMOPERATOR=" "
                END_IF/
    CCUSTOM    =COMMENT/INPUT,NO,FULL SCREEN=NO,
                ENTER TOOL
                ASSIGN/VCUSTOM=CCUSTOM.INPUT
                IF/CCUSTOM.INPUT == 0
                ASSIGN/VCUSTOM=" "
                END_IF/
    CREMARKS   =COMMENT/INPUT,NO,FULL SCREEN=NO,
                ENTER OPTIONAL REMARKS IF DESIRED (30 CHARACTERS MAX)
                ASSIGN/VREMARKS=CREMARKS.INPUT
                IF/CREMARKS.INPUT == 0
                ASSIGN/VREMARKS=" "
                END_IF/
                TRACEFIELD/NO_DISPLAY,LIMIT=43 ; Part : VPART
                TRACEFIELD/NO_DISPLAY,LIMIT=7 ; Rev : VREV
                TRACEFIELD/NO_DISPLAY,LIMIT=43 ; Description : VDESCRIPTION
                TRACEFIELD/NO_DISPLAY,LIMIT=16 ; Serial Number : VSERIALNUMBER
                TRACEFIELD/NO_DISPLAY,LIMIT=11 ; Operator : VCMMOPERATOR
                TRACEFIELD/NO_DISPLAY,LIMIT=16 ; Tool : VCUSTOM
                TRACEFIELD/NO_DISPLAY,LIMIT=30 ; Remarks : VREMARKS
                TRACEFIELD/NO_DISPLAY,LIMIT=11 ; Program ID : VPROGRAMID
                TRACEFIELD/NO_DISPLAY,LIMIT=22 ; Hardware : VHARDWARE
                TRACEFIELD/NO_DISPLAY,LIMIT=22 ; Software : VSOFTWARE
                ASSIGN/VDATE=SYSTEMDATE("dd''MMM''yyyy")
                ASSIGN/VTIME=SYSTEMTIME("hh''mm")


    And this is the script for the script call that is right below the VTIME line:

    Sub Main
    
    'Declares the File System Object And Instantiates it
    Dim  objFSO
    Set  objFSO = CreateObject("Scripting.FileSystemObject")
    
    'Declares PC-DMIS As the Active Program/Application
    Dim PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set Part = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    'Declares Variables from the prg As Objects
    
    Dim VPART As Object
    Dim VDESCRIPTION As Object
    Dim VSERIALNUMBER As Object
    Dim VDATE As Object
    Dim VTIME As Object
    Dim RESULTS As String
    
    
    'Pulls the variables from the prg
    
    Set  VPART = Part.GetVariableValue ("VPART")
    Set  VDESCRIPTION = Part.GetVariableValue ("VDESCRIPTION")
    Set VSERIALNUMBER = Part.GetVariableValue ("VSERIALNUMBER")
    Set VDATE = Part.GetVariableValue ("VDATE")
    Set  VTIME = Part.GetVariableValue ("VTIME")
    
    'Declares the Filepath, Folder, And the Filename As a String
    
    strPath = Part.Path     'Uses the prg path As the path For the folder
    
    
    'Sets the folder Name And the Path For the Folder
    strFolderName = VPART.StringValue & "_" & VDESCRIPTION.StringValue & "_" & VSERIALNUMBER.StringValue & "_" & VDATE.StringValue & "_" & VTIME.StringValue
    strFolder = strPath & "RESULTS\" & strFolderName
    
    'This command creates the folder
    Set objFolder = objFSO.CreateFolder(strFolder)
    
    End Sub


    Thanks everyone for all of the help.
Children
No Data