Write variables and measured data into txt file

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

  • Write variables and measured data into txt file

    Hi, is it possible to export some variables and the measured data from the measurement in a txt file?? I only know how to write variables into a txt file by using the following code:

    Code:
    EXPVAR     =FILE/OPEN,D:\VAREXP.TXT,WRITE
                FILE/WRITELINE,EXPVAR,CAVITY + ", " + PRODLINE + ", " + WERKTUIG + ", " + TEKNR + ", " + OPNAME + ", " + PRODUCTTYPE
                FILE/CLOSE,EXPVAR,KEEP
    But is there also an option to write the measured values into text?? It needs to be applicable for all measurement routines, so I can't define the measured data from one measurement routine.

  • #2
    In your case, you should open the file at the start of the program :
    Code:
    FPTR     =FILE/OPEN,D:\VAREXP.TXT,WRITE
    (or ADD)
    Then after each dimension, write the line :
    Code:
    FILE/WRITELINE,FPTR,DIST1.MEAS,,
    FILE/WRITELINE,FPTR,DIM1.X.MEAS,,
    (...)
    and at the end, close the file
    Code:
    FILE/CLOSE,FPTR,KEEP

    Comment


    • #3
      Under the help file, maybe

      ”Exporting to a Generic Text File”

      could work.

      B&S CHAMELEON/PCDMIS CAD++ V2011

      There are no bugs, only "UNDOCUMENTED ENHANCEMENTS!"

      sigpic

      Comment


      • #4
        OK, seems to work now. I have written a document line which is to be show in report. However when I use print command, then I can only choose between pdf, rtf and txt, but I need both pdf and txt!

        Comment


        • #5
          I don't understand your question.

          Couldn't you just have the writeline (print to txt) command and then the print command to pdf right below it?

          Comment


          • #6
            Code:
            SUBROUTINE/WRITE_TO_TXT,
                              PART =  : INPUT: ROUTINES PART#,
                              SERIAL =  : INPUT: STRING OF TEXT FLOWED DOWN FROM PLC,
                              FNAME =  : INPUT: ARRAY OF FEATURE OBJECTS EX. ASSIGN TYPE ARRAY({F1},{F2},{F3}),
                              RETURN =  : RETURN: STRING OF FEATURE TYPE (IF NOT NULL),
                               =
                          ASSIGN/SERNUM=RIGHT(SERIAL,LEN(SERIAL)-INDEX(SERIAL,"-"))
                          ASSIGN/TXTFILE1="C:\USERS\PUBLIC\DOCUMENTS\WAI\PC-DMIS\2015.1\PN_"+PART+"_SN_"+SERNUM+".txt"
                          ASSIGN/COUNTER=0
            FPTR         =FILE/OPEN,TXTFILE1,WRITE
                        DO/
                        ASSIGN/COUNTER=COUNTER+1
                        ASSIGN/FTYPE=GETTEXT(486,0,FNAME[COUNTER]) + GETTEXT(63,0,FNAME[COUNTER])
                        IF/FNAME[COUNTER].XYZ==0 AND FNAME[COUNTER].IJK==0
              $$ NO,
                          passing generic var value
                          FILE/WRITELINE,FPTR,"VAR<"+FNAME[COUNTER]+">"
                        END_IF/
                        ELSE/
                          SELECT/FTYPE
                            CASE/"CIRCLE"
                              FILE/WRITELINE,FPTR,"CIRCLE"+FNAME[COUNTER].XYZ +";"+ FNAME[COUNTER].IJK +";"+ FNAME[COUNTER].D
                            END_CASE/
                            CASE/"CYLINDER"
                              FILE/WRITELINE,FPTR,"CYLINDER"+FNAME[COUNTER].XYZ +";"+ FNAME[COUNTER].IJK +";"+ FNAME[COUNTER].D +";"+ FNAME[COUNTER].L
                            END_CASE/
                            CASE/"PLANE"
                              FILE/WRITELINE,FPTR,"PLANE"+FNAME[COUNTER].XYZ +";"+ FNAME[COUNTER].IJK
                            END_CASE/
                            CASE/"LINE"
                              FILE/WRITELINE,FPTR,"LINE"+FNAME[COUNTER].XYZ +";"+ FNAME[COUNTER].IJK+";"+FNAME[COUNTER].LENGTH
                            END_CASE/
                            DEFAULT_CASE/
                              FILE/WRITELINE,FPTR,FNAME[COUNTER].XYZ +";"+ FNAME[COUNTER].IJK
                            END_DEFAULTCASE/
                          END_SELECT/
                        END_ELSE/
                        IF/!FNAME.LEN==COUNTER
                          ASSIGN/RETURN=RETURN + FTYPE + " "
                        END_IF/
                        ASSIGN/FTYPE=""
                        UNTIL/COUNTER==LEN(FNAME)
                        FILE/CLOSE,FPTR,KEEP
                        ENDSUB/
            It works on most features... On the ones that don't work you have to build generic features from and pass those instead.

            On your PcD program should have something like:
            Code:
                        ASSIGN/PART="PART#-n"
                        ASSIGN/PLC_DATA="PART#-n_Rev_OP,JOB-Ser#"
                        ASSIGN/SERIAL=RIGHT(PLC_DATA,LEN(PLC_DATA)-INDEX(PLC_DATA,",")) or "JOB-Ser#"
                        ASSIGN/VAR123="Test1"
                        ASSIGN/VAR456=777
                        ASSIGN/FNAMES=ARRAY({CIR5},{CIR6},VAR123,VAR456)
            
                        ****Measure features here****
            
            CS1        =CALLSUB/WRITE_TO_TXT,C:\Users\Public\Documents\WAI\PC-DMIS\2015.1\Subroutines\SubRoutineLibrary.PRG:PART,SERIAL,FNAMES,,,
            
                        End Part program
            I'll post code for 'reading' in txt file.

            I got tired of writing the bunch of line over and over to write to txt files.
            Last edited by Kp61dude!; 08-10-2018, 09:35 AM.
            PcDmis 2015.1 SP10 CAD++
            Global 7-10-7 DC800S

            Comment


            • #7
              Example:

              Part: Delete-1
              Rev: A
              Operation: 50
              Job-Ser#: 987123-1

              Code:
              $$ NO,
                          _____________________________________________________________________________________________
              
                                                            Export data for OP50.
                          _____________________________________________________________________________________________
              
              EXPORT_ALN =ALIGNMENT/START,RECALL:ABC_ALN,LIST=YES
                            ALIGNMENT/ROTATE_OFFSET,180,ABOUT,YPLUS
                          ALIGNMENT/END
                          ASSIGN/FEATURES=ARRAY({P1_2},{P1_4},{PLN2},{PLN3},{P2_7},{P2_8},{P1},{P2},{P3},{P4},{P5},{P6},{P7},{P8},{P9},{P10},{P11},{P12},{PLN4},{PLN5},{PLN6})
              EXPORTDATA =CALLSUB/WRITE_TO_TXT,C:\Users\Public\Documents\WAI\PC-DMIS\2015.1\Subroutines\SubRoutineLibrary.PRG:PART,SERIAL,FEATURES,,
                          RECALL/ALIGNMENT,INTERNAL,BAC_ALN
              Writes txt file: "PN_Delete-1_SN_1.TXT"
              Contents:
              <-0.51, 1.35, -2.4632>;<1, 0, 0>
              <0.51, 1.35, -2.4382>;<-1, 0, 0>
              PLANE<0.9981, 3.0119, -1.5083>;<-0.9225, -0.075, -0.3786>
              PLANE<-0.9981, 3.0119, -1.5083>;<0.9225, -0.075, -0.3786>
              <0, 2.7364, -0.0433>;<0, -0.4652, -0.8852>
              <0, 3.8773, -0.643>;<0, -0.4652, -0.8852>
              <0.728, 4.0204, -2.5382>;<0, 0, -1>
              <0.5138, 4.1272, -2.5382>;<0, 0, -1>
              <0.3395, 4.3464, -2.5382>;<0, 0, -1>
              <-0.3395, 4.3464, -2.5382>;<0, 0, -1>
              <-0.5138, 4.1272, -2.5382>;<0, 0, -1>
              <-0.728, 4.0204, -2.5382>;<0, 0, -1>
              <0.728, 5.1796, -2.5382>;<0, 0, -1>
              <0.4976, 5.0596, -2.5382>;<0, 0, -1>
              <0.3395, 4.8536, -2.5382>;<0, 0, -1>
              <-0.3395, 4.8536, -2.5382>;<0, 0, -1>
              <-0.4976, 5.0596, -2.5382>;<0, 0, -1>
              <-0.728, 5.1796, -2.5382>;<0, 0, -1>
              PLANE<1.0357, 5.6879, -2.13>;<-0.9225, -0.075, -0.3786>
              PLANE<0, 5.7155, -1.6091>;<0, -0.4652, -0.8852>
              PLANE<-1.0357, 5.6879, -2.13>;<0.9225, -0.075, -0.3786>
              PcDmis 2015.1 SP10 CAD++
              Global 7-10-7 DC800S

              Comment


              • #8
                Kp61dude! Thanksss!

                Comment


                • Kp61dude!
                  Kp61dude! commented
                  Editing a comment
                  Did you get it to work?
              Working...
              X