hexagon logo

Printing reports with serial # as file name.

I output a PDF report for every part I check and I currently use auto indexing to name them. There is a report comment at the beginning of the program that asks for the serial # of the part. I was wondering if it's possible to instead have PC DMIS automatically add that same serial # to the end of the file name instead of the index #. This would be helpful if I need to find the report for a specific piece later. I know I could just manually type it in each time. I'm just looking for a more efficient method since the serial #'s are often over 20 characters and I never remember what it was at the end of the program and I'd rather not take it off the machine before viewing the report in case I need to remeasure something. Am I asking too much here?
  • The "YES" in the Comment will print the Ser Num at the top of each report.
  • Thanks for all the advice, but I think this is now out of my league.


    It is quite simple. If you change the view to command mode momentarily to edit one thing, and then change it back, you will be good.

    Create a new variable with "GETPROGRAMINFO("SERIALNUM")". This will grab the serial number you define in the 'File Header' of the program. I have assigned the name of 'SN' but it can be anything you'd like.

    Then, you'll want to do "Insert -> Report Command -> Print Command"

    You can then edit that to select the correct file location. Select the option "Auto".

    Once done, you will want to switch to command mode if you arent already in command mode. You should see the assign and print commands. Under the print command you will want to change part of the second line from "AUTO=1" to "AUTO=SN". This should then automatically add the serial number on to the end of the file name each time.

    Hope this helps more than my previous response. Below is a snip of the code.

    ASSIGN/SN=GETPROGRAMINFO("SERIALNUM")
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,AUTO=SN,OUTPUT_FORMAT/PDF,$
                  RESET_REPORT=YES,AUTO OPEN=OFF,$
                  TO_PRINTER=OFF,COPIES=1,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  TO_EXCEL=OFF,$
                  PREVIOUS_RUNS=DELETE_INSTANCES​
  • Just to make people aware, there is an example routine that you can download from the "Discover" tab of the PC-DMIS home page (available from versions 2020 R1 onwards). It's under "report archiving".
  • Try this. If you are looping your program, this code must be inside loop, at the beginning.

    C5 =COMMENT/INPUT,YES,FULL SCREEN=NO,
    Serial Number
    ASSIGN/SER_NUM=C5.INPUT​


    Add a Print Command at the end of the loop and F9 on the Report Command. In the Report tab, check the Report output box, click on the drop-down and navigate to the destination folder for the report.
    In the File name box at the bottom, type the intended name of the reports followed by an underscore(_). Ex: X4262148_
    Save and click "OK" in the Report command.

    Back in the Edit window change the "1" after AUTO to "SER_NUM"

    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=OFF,AUTO=SER_NUM,AUTO OPEN=OFF,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME=,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES​


    Each report will have the serial number as part of the filename.


    I don't understand. If I type the code as you have shown, it just puts the ASSIGN/SER_NUM=C5 as part of the comment text.

  • Hit enter 2x before attempting to input an Assignment command. 1x will just move to the next row to continue typing your text.
  • I tried hitting enter twice, it just pushes the assignment command back up and it still ends up as comment text.
  • If you put the following in a bas module and call it with the argument for the new serial number, it will replace it in the header of the program and the report.

    Sub Main(SN As String)
    On Error GoTo err_Hand:
    
    Dim App As Object
    Set App = CreateObject("PCDLRN.Application")
    
    Dim Part As Object
    Set Part = App.ActivePartProgram
    
    Part.serialnumber = SN
    Part.refreshpart
    
    Dim RepWindow As Object
    Set RepWindow = Part.reportwindow
    RepWindow.refreshreport
    
    Exit Sub
    err_Hand:
    MsgBox err.number
    MsgBox err.description
    Exit Sub
    End Sub
  • I think I may have gotten it to work by using "overwrite" instead of "auto."

    ASSIGN/V1=C5.INPUT
    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,OVERWRITE="W:\pc-dmis files\McBride\validator data\146-3091 complete 2_"+V1,AUTO OPEN REPORT=OFF,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME= ,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
    TO_EXCEL_OUTPUT=OFF,
    PREVIOUS_RUNS=DELETE_INSTANCES​
    
  • Or you can click "Insert/Assignment" to add the Assignment.