hexagon logo

Save reports in PDF automatically and use date and time as name

Hi,

I want to save the reports automatically after every run and use date and time for the name file. How I can do that?

Thanks!
  • GETPROGRAMINFO

    This function returns the measurement routine's information based on the parameters passed in: GETPROGRAMINFO(<String>, <Optional String>Wink

    This function has at most two strings as parameters. For most items, you only need the first parameter. The string fields are not case sensitive.

    First Field—String

    The first field is a string input detailing what information to return.

    DATE - Returns the current date.

    TIME - Returns the current time.

    PARTNAME - Returns the part name as defined in the measurement routine header.

    PARTPATH - Returns the full pathway to the measurement routine file.

    REVISION - Returns the revision number as defined in the heading.

    DRAWING - Like REVISION, this also returns the revision number as defined in the heading.

    SERIALNUM - Returns the serial number as defined in the header.

    STATSCOUNT - Returns the current stats count.

    SEQNUM - Like STATSCOUNT, this string also returns the current stats count number.

    SHRINK - Returns the global scale factor.

    NUMMEAS - Returns the number of dimensions executed.

    NUMOOT - Returns the number of out of tolerance dimensions executed.

    ELAPSEDTIME - Returns the time that has passed since the beginning of the execution.

    FILENAME - Returns the measurement routine's file name (.prg).

    CADMODELFILE - Returns the full path to the file name of the CAD model that you imported into the measurement routine.

    CADMODELFILENAME - Returns the name of only the CAD model (not the path) that you imported into the measurement routine.

    REPORTNAME - Returns the current output file name.

    TEMP - Returns the temperature for the optional second input string. See "Second Field—Optional String" below.

    PRGVERSION - Returns a string value of the PC-DMIS version number of the measurement routine file. You can save a measurement routine file to be compatible with a specific version. For more information, see " Save As" in the " Using Basic File Options" chapter.

    PRGSCHEMA - Returns an integer of the PC-DMIS schema number of the measurement routine file. This is an internal value used by PC-DMIS used to indicate the commands and options that are serialized.

    PCDMISVERSION - Returns a string value of the actual installed version of the PC-DMIS software.

    Second Field—Optional String

    The second field is an optional string input. It's only needed if TEMP is used in the in the first input field. The possible strings below come from the Temperature Compensation command. For more information, see " Compensating For Temperature" in the " Setting Your Preferences" chapter.

    TEMPP - Returns the temperature for the part sensor

    TEMPX - Returns the temperature for the X axis sensor

    TEMPY - Returns the temperature for the Y axis sensor

    TEMPZ - Returns the temperature for the Z axis sensor

    REF_TEMP - Returns the reference temperature

    HIGH_THRESHOLD - Returns the high threshold temperature

    LOW_THRESHOLD - Returns the low threshold temperature

    Example

    $$ NO, This code sample displays the number of total dimensions and the number of out-of-tolerance dimensions.

    ASSIGN/V1=GETPROGRAMINFO("NUMMEAS")

    ASSIGN/V2=GETPROGRAMINFO("NUMOOT")

    COMMENT/REPT

    "Total Dimensions: "+V1

    "Total Out of Tolerance: "+V2

    $$ NO,This code sample returns the temperature on the Z sensor axis.

    ASSIGN/V3=GETPROGRAMINFO("TEMP", "TEMPZ")

    COMMENT/REPT

    "Temperature on the Z axis: "+V3

    https://docs.hexagonmi.com/pcdmis/2020.1/en/helpcenter/index.htm?rhcsh=1&rhnewwnd=0#t=mergedProjects%2Fcore%2F26_expression_topics%2FString_Functions.htm
  • What is the program info for revision number?

    I've tried

    REVISIONNUMBER
    REVISION_NUMBER
    REVISION NUMBER
    REVNUMBER
    REV_NUMBER
    REV NUMBER
    REVNUM
    REV_NUM
    REV NUM


    ASSIGN/XXXXXX=GETPROGRAMINFO ("REVISION")

    Returns the revision number as defined in the heading.

    https://docs.hexagonmi.com/pcdmis/2021.1/en/helpcenter/index.htm?rhcsh=1&rhnewwnd=0#t=mergedProjects%2Fcore%2F26_expression_topics%2FString_Functions.htm&rhsearch=getprograminfo&rhhlterm=getprograminfo&rhsyns=%20
  • Thank you! You are so awesome. Also thanks for that link/ I could have used a list like that from the beginning, haha.
  • I hate to re-hash this, but I've tried everything I know (plus a ton of Google searches to the forum) to get my program to auto-save based on operator inputs (Job #/ Sample number).
    Right now, at the end of the program, the operator just names the report based on the sample number. However, they are prone to not pay attention to where they are saving, and once they save it to the wrong folder, it's next to impossible to find the report. So, i was trying to name the report by this standard:

    <Program Folder>/Reports/<Part Number>_<Job Number>_<Date>_<Sample Number>.pdf


    Here is the top of the program, where the operator is asked to input the job number, sample number, and operator initials...

    STARTUP    =ALIGNMENT/START,RECALL:USE_PART_SETUP,LIST=YES
                ALIGNMENT/END
                MODE/MANUAL
                FORMAT/TEXT,OPTIONS,ID,HEADINGS,SYMBOLS, ;NOM,TOL,MEAS,MAXMIN,DEV,DEVANG,OUTTOL
                MOVESPEED/ 200
                FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,TOL,MEAS,DEV,OUTTOL, ,
                COMMENT/OPER,YES,FULL SCREEN=YES,AUTO-CONTINUE=NO,
                ****TEST PROGRAM OFFLINE ONLY NOT FOR FAIs/IPs****
                LOADPROBE/EPS POINT5X20
                TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
                COMMENT/OPER,NO,FULL SCREEN=YES,AUTO-CONTINUE=NO,
                PLACE PART IN RAPTOR FIXTURE AS SHOWN.
                PLACE PEGS AT I-4, I-9, & H-11.
    C1         =COMMENT/INPUT,YES,FULL SCREEN=NO,
                INPUT JOB NUMBER
                ASSIGN/V2=C1.INPUT
    C3         =COMMENT/INPUT,YES,FULL SCREEN=NO,
                INPUT PART COUNT
                ASSIGN/V1=C3.INPUT
    C2         =COMMENT/INPUT,YES,FULL SCREEN=NO,
                INPUT OPERATOR  
                ASSIGN/V3=C2.INPUT
                LOADPROBE/EPS POINT5X20
                TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
    MANALIN    =COMMENT/YESNO,NO,FULL SCREEN=YES,AUTO-CONTINUE=NO,
                
                
                DO YOU NEED TO RUN MANUAL ALIGNMENT?
                
                ​



    Here is the end of the program with the attempt to auto-name, where it calls up the variables to create the folder path, name the file, and saves the report to PDF (the FreeBasic scripts are below the program code):

    END =GROUP/SHOWALLPARAMS=YES
    COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    **END OF PROGRAM HERE**
    SAVE_REPORT =GROUP/SHOWALLPARAMS=YES
    $$ NO,
    --------------------------------------------------------
    UPDATE FOLDERPATH inside of tracefield below TO ACTUAL REPORT
    location (COPY AND PASTE AND ADD A "/" TO THE END) for
    PART SPECIFIC LOCATION example below
    "M:\DMR\CMM PROGRAMS\>cust name<\>part num<\REPORTS/"
    --------------------------------------------------------
    ASSIGN/FOLDERPATH="O:\EMPLOYEE FOLDER\GREBE\_CMM_TEST\EPS-C1054-3-N REV A"
    WORKPLANE/ZPLUS
    ASSIGN_FILENAME =GROUP/SHOWALLPARAMS=YES
    ASSIGN/FOLDERNAME=FOLDERPATH+"\REPORTS\"+V2+"\"
    ENDGROUP/ID=ASSIGN_FILENAME
    ASSIGN/PRINT_PATH=FOLDERNAME+GETPROGRAMINFO("PARTNAME")+" _"+ V2+"_"+SYSTIME()+"_"+V1+".PDF"
    CREATE_FOLDER =GROUP/SHOWALLPARAMS=YES
    $$ NO,
    --------------------------------------------------------------
    CREATES THE FOLDER, IF NEEDED.
    WILL POP UP A WARNING IF FOLDER IS ALREADY CREATED,
    CLICK OK ON DIALOG BOX TO CONTINUE
    --------------------------------------------------------------
    CS1 =SCRIPT/FILENAME= "M:\DMR\CMM PROGRAMS\_SCRIPTS\CREATE.BAS"
    FUNCTION/PCDCreatefolder,SHOW=YES,ARG1=PRINT_PATH,,
    STARTSCRIPT/
    ENDGROUP/ID=CREATE_FOLDER
    REDRAW =GROUP/SHOWALLPARAMS=YES
    $$ NO,
    Redraws the Report Window before saving.
    CS2 =SCRIPT/FILENAME= "M:\DMR\CMM PROGRAMS\_SCRIPTS\REDRAW.BAS"
    FUNCTION/Main,SHOW=YES,,
    STARTSCRIPT/
    ENDGROUP/ID=REDRAW
    SAVE_PDF =GROUP/SHOWALLPARAMS=YES
    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,AUTO=PRINT_PATH,AUTO OPEN=OFF,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME= FOLDERNAME,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES
    ENDGROUP/ID=SAVE_PDF
    ENDGROUP/ID=SAVE_REPORT
    ENDGROUP/ID=END
    


    Here are the 2 scripts i created, one to create the folder, and the later to "redraw" the report:

    '
    ' CREATED BY B. GREBE 21 AUG 23
    ' CODE SOURCE: PC-DMIS ONLINE FORUM (FREE USE)
    ' LANGUAGE: FREEBASIC (For PC-DMIS)
    ' Function: To CREATE THE SAVE FOLDER For THE PDF CMM REPORT
    '
    Sub Main()
    
    Dim objFSO, objShell
    Dim PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval
    Dim objFile, objFolder As Object
    
    Set PCDApp=CreateObject("PCDLRN.Application")
    Set PCDPartProgram=PCDApp.ActivePartProgram
    Set PCDCommands=PCDPartProgram.Commands
    
    'Grabs FolderName from PCD part program
    
    Set Pathname=PCDPartProgram.GetVariableValue("FOLDERNAME")
    
    'Sets Pathname As String value
    
    strPath=Pathname.StringValue
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    'Creates folder On Netowrk Drive If Needed
    
    If objFSO.FolderExists(strPath) Then
    'Nothing
    Else
    Set objFile=objFSO.CreateFolder(strPath)
    End If
    
    'Cleanup
    Set pcdReportWindow = Nothing
    Set pcdPart = Nothing
    Set pcdApp = Nothing
    Set Pathname = Nothing
    Set objFSO = Nothing
    
    End Sub​


    '
    ' CREATED BY B. GREBE 21 AUG 23
    ' CODE SOURCE: PC-DMIS ONLINE FORUM (FREE USE)
    ' LANGUAGE: FREEBASIC (FOR PC-DMIS)
    ' FUNCTION: TO 'REDRAW' THE CMM REPORT PRIOR TO SAVING
    '
    Sub Main()
    
    
    '************PC-DMIS declarations************
    Dim pcdApp As Object
    Set pcdApp = CreateObject("PCDLRN.Application")
    
    Dim pcdPart As Object
    Set pcdPart = pcdApp.ActivePartProgram
    
    Dim pcdReportWindow As Object
    Set pcdReportWindow = pcdPart.ReportWindow
    
    '***********Repaint the report window*********
    pcdReportWindow.RefreshReport
    
    '********************Cleanup**********************
    Set pcdReportWindow = Nothing
    Set pcdPart = Nothing
    Set pcdApp = Nothing
    
    End Sub​


    Maybe i'm in over my head, or just a small oversight error...
    Thanks in advance.
  • You are using the REPORT_NAME variable name for both the pass and fail, try naming them differently and see if that fixes the issue.
  • I created this years ago with help from several programmers from the "far side". You will need the batch files that are needed and this makes it as idiot proof (even though new idiots are released daily). We used bar code scanners for all of the inputs including opening the programs. This gives the operators the option of printing, file only (pdf) or both and will not allow a pdf to be created if the part failed inspection

    Start inch program https://app.box.com/s/kmiq9dox2w8ft3tqqp51zoavimqnx8v1

    Start metric program https://app.box.com/s/roheplrs2fop16ixq54r

    Batch file as text https://app.box.com/shared/k7vdp0nh9b

    Batch file https://app.box.com/shared/vc5b91unn5
  • Didn't realize when you insert a Script command in PC-Dmis, by default it marks it as skipped.. as soon as I marked them, it ran without a hitch.