How to automate S/N input each run

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to automate S/N input each run

    Currently, I'm manually changing the serial number in the file header before I execute the program on each part so it shows up in the header of my inspection report. Then I manually input the S/N as the file name when I print the report. Is there some kind of comment or assignment I can use so I input the S/N once each time I execute the program that will put it in my report header and auto print the report named as that S/N?

  • #2
    You can use a script like this to set the part name, revision number and serial number.

    Code:
    Dim DmisApp As Object
    Dim DmisPart As Object
     
    Sub Main(New_Part As String, New_Rev As String, New_Ser As String)
    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    
    If New_part <> "" Then
    DmisPart.PartName = New_Part
    End If
    If New_Rev <> "" Then
    DmisPart.RevisionNumber = New_Rev
    End If
    If New_Ser <> "" Then
    DmisPart.SerialNumber = New_Ser
    End If
    DmisPart.RefreshPart
    End Sub
    In your PC-Dmis routine you would add a basic script command and pass in the fields you want to change as arguments. If any argument is missing or left blank it is ignored. This is what the edit window text would look like (in command mode)

    Code:
    CS1 =SCRIPT/FILENAME= C:\USERS\PUBLIC\DOCUMENTS\SCRIPTS\CHANGE_PROG_HEAD ER.BAS
    FUNCTION/Main,SHOW=YES,ARG1="My_new_part_name",ARG2="5",ARG 3="12345",,
    STARTSCRIPT/
    Neil Challinor
    PC-DMIS Product Owner

    T: +44 870 446 2667 (Hexagon UK office)
    E: [email protected]

    Comment


    • #3
      You can create a custom report header.. and then use a variable from an input comment.. OR... input from a tracefield.. and use that to populate a field in your header.

      I do something different, code is below. It will show a Serial Number and a Run Number as a report comment on the inspection report.

      Code:
      GROUP_SERIALNUMBER_AND_RUNNUMBER=GROUP/SHOWALLPARAMS=YES
      SERIALNUMBERQUESTION =COMMENT/INPUT,NO,FULL SCREEN=NO,
      Serial Number:
      ASSIGN/VAR_SERIAL_NUMBER=UPPERCASE(SERIALNUMBERQUESTION.I NPUT)
      ASSIGN/VAR_SERIALNUMBER_STATEMENT="Serial Number: "+VAR_SERIAL_NUMBER
      COMMENT/REPT,
      
      COMMENT/REPT,
      VAR_SERIALNUMBER_STATEMENT
      RUNNUMBERQUESTION =COMMENT/INPUT,NO,FULL SCREEN=NO,
      Run Number:
      IF_GOTO/RUNNUMBERQUESTION.INPUT<1 OR RUNNUMBERQUESTION.INPUT>9999,GOTO = RUNNUMBERQUESTION
      IF_GOTO/LEN(RUNNUMBERQUESTION.INPUT)>4,GOTO = RUNNUMBERQUESTION
      ASSIGN/VAR_RUNNUMBER=FORMAT("%04d",INT(RUNNUMBERQUESTION. INPUT))
      ASSIGN/VAR_RUNNUMBER_STATEMENT="Run Number: "+VAR_RUNNUMBER
      COMMENT/REPT,
      VAR_RUNNUMBER_STATEMENT
      ENDGROUP/ID=GROUP_SERIALNUMBER_AND_RUNNUMBER
      SF7107(PCD), SF454(PCD), 152614(Quindos), 9159(Quindos), 7107(Quindos), B&S Manual, M&M Gear Checker

      Comment


      • #4
        neil.challinor that actually brings up my next major problem. PC-DMIS crashes every time I try to run a script. This one included.
        Last edited by bjgalbreath; 03-30-2021, 12:59 PM.

        Comment


        • neil.challinor
          neil.challinor commented
          Editing a comment
          What version are you running? There was a bug in PC-Dmis 2017 R2 that caused scripts to crash due to a permissions problem. It was fixed in 2017 R2 SP11.

        • bjgalbreath
          bjgalbreath commented
          Editing a comment
          2018 r2 sp 8

      • #5
        DAN_M I actually am using a custom report header and originally had the prompt each run text box I found in a automettech video, but I couldn't find a way to put that into my print report file name to keep from having to input it multiple times. Same goes with the input comment variable. How would I use that to populate the file name when printing the report?
        Last edited by bjgalbreath; 03-30-2021, 03:58 PM.

        Comment


        • #6
          C1 = COMMENT/INPUT "Enter serial number"

          ASSIGN/PARTNUM="ABC123"
          ASSIGN/SERNUM=C1.INPUT

          ASSIGN/REPORTPATH="C:\CMM_REPORTS"+PARTNUM+"_"+SERNUM+".P DF"

          Fees that into a PRINT command to save the report.

          In the report template use a text object and set it to the value

          =VARIABLE("SERNUM")

          I think I cover that in one of the reporting videos (I'm Automettech btw) - I'll check which one it's in tomorrow.


          Edit : about 5 mins into this video.

          https://www.automettech.com/reporting5
          Last edited by NinjaBadger; 03-30-2021, 06:25 PM.
          Automettech - Automated Metrology Technology

          Comment


          • #7
            I have the header figured out, and it does auto-save the PDF, however, it keeps naming it 001.pdf instead of the serial number. And it won't save it into the sub folder I'm telling it to.

            Comment


            • neil.challinor
              neil.challinor commented
              Editing a comment
              Switch the mode to APPEND instead of AUTO

          • #8
            neil.challinor that creates a blank name pdf and still doesn't put it into the sub folder. It also adds onto the same pdf when I run the program a second time.
            Last edited by bjgalbreath; 03-31-2021, 10:44 AM.

            Comment


            • #9
              I use OVERWRITE not APPEND or AUTO - you just need to ensure it is a unique file name (you can test if the file exists within PC-Dmis.)

              Insert menu > File IO (or something like that).

              Automettech - Automated Metrology Technology

              Comment


              • #10
                NinjaBadger the problem is trying to make it the unique name. APPEND and OVERWRITE will name the file with blank. AUTO will at least index them with each run. 001, 002, 003. But nothing I am doing is naming it the serial number that I want it to. Or putting it into the sub folder to keep things organized.

                Comment


                • #11
                  i have this at the beginning of the program:

                  JN =COMMENT/INPUT,NO,FULL SCREEN=NO,
                  JOB NUMBER
                  SN =COMMENT/INPUT,NO,FULL SCREEN=NO,
                  SERIAL #


                  All of my dimensions are reported at the end of the program, with this at the top of the report:


                  COMMENT/REPT,
                  "JOB NUMBER: "+JN.INPUT
                  COMMENT/REPT,
                  "SERIAL NUMBER: MAP00"+SN.INPUT
                  COMMENT/REPT,
                  =====================================


                  And then at the very end of the program, I have this:


                  ASSIGN/PROG_NAME=GETPROGRAMINFO("PARTNAME")
                  ASSIGN/REPORT_NAME="J:\\Production\\Jobs\"+JN.INPUT+"\\C MM-001\"+PROG_NAME+"SERIAL#00"+SN.INPUT+".PDF"
                  PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,PROMPT,AUTO OPEN=ON,$
                  TO_PRINTER=OFF,COPIES=1,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME= ,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
                  TO_EXCEL=OFF,$
                  PREVIOUS_RUNS=KEEP_INSTANCES

                  Comment


                  • #12
                    It's simply not working and it looks like I'm doing everything right. When I mouseover my filename, it does as it should. But it still saves as an indexed number. Or blank name. And it only saves in the same folder as the part program. Could the save location be because I'm trying to save in a network drive but don't have a drive letter?
                    Attached Files
                    Last edited by bjgalbreath; 04-01-2021, 12:36 PM.

                    Comment


                    • #13
                      bjgalbreath - the path is not correct, the screen shot with the hover over tool tip showing starts with a single '\'

                      This will be your issue, you might probably need to start the file path with \\\ - I assume RPOG-FS1 is the server name?
                      Automettech - Automated Metrology Technology

                      Comment


                      • #14
                        \\\ does the exact same thing.

                        Yes, RPOG-FS1 is the server name.

                        Comment


                        • NinjaBadger
                          NinjaBadger commented
                          Editing a comment
                          You surte?

                          Check again...

                          This works for me


                          ASSIGN/SERNUM=1234
                          ASSIGN/REPPATH="\\\DEMON\AUTOMETTECH\TEMP\"+SERNUM+".PDF"
                          COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                          REPPATH
                          PRINT/REPORT,EXEC MODE=END,$
                          TO_FILE=ON,OVERWRITE=REPPATH,AUTO OPEN REPORT=OFF,$
                          TO_PRINTER=OFF,COPIES=1,$
                          TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                          REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
                          TO_EXCEL_OUTPUT=OFF,$
                          PREVIOUS_RUNS=DELETE_INSTANCES

                      • #15
                        NinjaBadger that does not work for me.

                        I'm not sure what the REPPATH comment is supposed to accomplish? Either way, both the comment popup and the pdf file say 0 and it still doesn't save into the sub folder.

                        Code:
                        C1 = COMMENT/INPUT,NO,FULL SCREEN=NO,
                        INPUT SERIAL NUMBER
                        ASSIGN/SERNUM=(C1.INPUT)
                        
                        ASSIGN/REPPATH="\\\RPOG-FS1\qc\PC-DMIS\118010-10-1 - A7\Reports\"+SERNUM+".PDF"
                        COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                        REPPATH
                        PRINT/REPORT,EXEC MODE=END,$
                        TO_FILE=ON,OVERWRITE=REPPATH,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
                        Last edited by bjgalbreath; 04-09-2021, 09:04 AM.

                        Comment


                        • NinjaBadger
                          NinjaBadger commented
                          Editing a comment
                          Loose the brackets from

                          ASSIGN/SERNUM=(C1.INPUT)

                          The operator comment is a way of debugging - shows what value the variable SERNUM holds at that point. In your case it's showing 0 which is incorrect.

                      Related Topics

                      Collapse

                      Working...
                      X