Multi Dimensional Array to Single Dimension Array

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

  • Multi Dimensional Array to Single Dimension Array

    Here's something I always seem to forget when I need it and have to think a little bit to remember (so why not document it here for my future self ps. you're memory is deteriorating quickly future self!).

    Code:
                ASSIGN/ARRAY_1=ARRAY({PNT69},{CIR16},{CIR17})
                ASSIGN/ARRAY_2=ARRAY({LIN12},{PLN6},{PLN7},{PLN8},{LIN13})
                ASSIGN/ARRAY_3=ARRAY({LIN14},{PLN9},{PLN10},{PLN11},{LIN15})
    $$ NO,
                load as many arrays into below vvvv
                ASSIGN/MULTI_ARRAY=ARRAY(ARRAY_1,ARRAY_2,ARRAY_3)
    $$ NO,
                Push all items in multi dimensional array into a single dimensional array.
                
                ASSIGN/SINGLE_ARRAY=0
                ASSIGN/CNT=1
                ASSIGN/O_CNT=1
                DO/
                ASSIGN/I_CNT=1
                DO/
                ASSIGN/SINGLE_ARRAY[CNT]=MULTI_ARRAY[O_CNT,I_CNT]
                ASSIGN/CNT=CNT+1
                ASSIGN/I_CNT=I_CNT+1
                UNTIL/I_CNT > LEN(MULTI_ARRAY[O_CNT])
                ASSIGN/O_CNT=O_CNT+1
                UNTIL/O_CNT > LEN(MULTI_ARRAY)
    You super users out there.. if you know a quicker, simpler, easier way to do this I would greatly appreciate it if you shared it below.
    Last edited by Kp61dude!; 03-23-2021, 03:27 PM.
    PcDmis 2015.1 SP10 CAD++
    Global 7-10-7 DC800S

  • #2
    That's how I'd do it.

    But I think Jeffman's the array king
    Applications Engineer
    Hexagon UK

    Comment


    • #3
      Originally posted by NinjaBadger View Post
      That's how I'd do it.

      But I think Jeffman's the array king
      JEFMAN is in a different league of his own!
      PcDmis 2015.1 SP10 CAD++
      Global 7-10-7 DC800S

      Comment


      • #4
        Try to do it less longer... but failed (only a line less...)
        NinjaBadger and Kp61dude! : it was a funny challenge !


        Code:
        ASSIGN/ARRAY1=ARRAY({PLN1},{PLN2})
        ASSIGN/ARRAY2=ARRAY({CIR1},{CIR2})
        ASSIGN/ARRAY3=ARRAY({PLN3},{CIR3})
        ASSIGN/ARRAY4=ARRAY({PLN4},{PLN5},{CIR4},{CIR5})
        ASSIGN/M_ARRAY=ARRAY(ARRAY1,ARRAY2,ARRAY3,ARRAY4)
        ASSIGN/CNT_1=0
        ASSIGN/CNT_2=1
        DO/
        ASSIGN/CNT_1=CNT_1+1
        ASSIGN/V1=M_ARRAY[CNT_1]
        V3 =LOOP/START,ID=YES,NUMBER=LEN(V1),START=1,SKIP=,
        OFFSET:XAXIS=0,YAXIS=0,ZAXIS=0,ANGLE=0
        ASSIGN/S_ARRAY[CNT_2]=V1[V3]
        ASSIGN/CNT_2=CNT_2+1
        LOOP/END
        UNTIL/CNT_1==LEN(M_ARRAY)
        COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
        S_ARRAY

        Comment


        • #5
          When you have the feature names enclosed in the "{" and "}" symbols within the array(s), what does that do?

          This code is cool, when would you use something like this?

          Comment


          • #6
            Originally posted by DAN_M View Post
            When you have the feature names enclosed in the "{" and "}" symbols within the array(s), what does that do?

            This code is cool, when would you use something like this?
            Those there are pointers to features.
            Example:
            Code:
             ASSIGN/V1={CIR10}
            $$ NO,
                        V1.X <-- this is the same as CIR10.X
            This probably has a few different uses.

            The use I was in need of that day was this:

            1. First think of the "line too long" error Pc-Dmis gives you when an assignment that is just too, well, long. To try this create an ASSIGN/V1 = ARRAY(<put something here that's too long>, <to break it>). In my case I had arrays with pointers to features eg. {CIR21} is a pointer to AUTO/FEATURE CIR21 that's a 2D circle.

            2. When it gets too long you have no choice but to break them up into multiple array variables (ASSIGN/V1=ARRAY()). When you do this you'll end up with your data broken up into different variables, not good when your Function only takes one variable array! So, you must take all of your data/variables and combine them into one.

            3. My brain always goes to this thought "hey, just take your variables and combine them into one array!" and I always, I mean always, make the mistake of using this:
            Code:
                        ASSIGN/ARRAY_1=ARRAY({PNT69},{CIR16},{CIR17})
                        ASSIGN/ARRAY_2=ARRAY({LIN12},{PLN6},{PLN7},{PLN8},{LIN13})
                        ASSIGN/ARRAY_3=ARRAY({LIN14},{PLN9},{PLN10},{PLN11},{LIN15})
                        ASSIGN/ARRAY_4=ARRAY({PNT35},{PNT51})
                        ASSIGN/ARRAY_ALL=ARRAY(ARRAY_1, ARRAY_2, ARRAY_3, ARRAY_4)
            which unfortunately doesn't yield what I expect!!!! It does not give the expected results, you'd think I'd remember what the above does exactly given that I commit this mistake a bunch but, I just don't remember what the above yields I just remember that it doesn't combine all of your arrays into one handy array (too easy, right?!). That is what the original post purpose was crated for... to assist me when my bad memory strikes again! Hopefully I remember that I made this post...
            UPDATE: memory came back.. the above is only parts way done. This creates a multi dimensional array (see original post for making it a single dimensional array).


            Now if you're wondering why I use these 'pointer to features'? Well that's a slightly different story...

            1. In my environment called the workplace and "the way we do things around here!" (imagine a hardcore east-coast mobster accent). We machine parts in multiple ops... sometimes some features will be milled in but will have no datums to measure them to and on the next operation the feature will be inaccessible (great! not great).

            2. What I do (not saying it's the best solution but it's my only goto solution that I thought up and have stuck to)... I measure the said feature export it's characteristics to a text file and then recreate it on the next OP via the builtin generic feature from the characteristics that were read in from the text file.

            3. I am lazy. I hate having to type stuff out over and over and then not to mention what long run maintenance will hinder me. My solution was to create a function with two inputs

            a. array of features and
            b. text file string

            to export. And on the next OP to import I have a function look for a text file that matches ID and part name (that's already in the program for other reasons) and it creates every feature in generic form that I can reference like this:
            first create what will create all the generic features in a subroutine
            Code:
            $$ NO,
                        _____________________________________________________________________________________________
                        
                        Import data
                        _____________________________________________________________________________________________
                        (alignment is translated at export so no need to create an 'Import Alingment')
                        
            CS1        =CALLSUB/BUILD_FROM_TXT,C:\Users\Public\Documents\WAI\PC-DMIS\2015.1\Subroutines\SubRoutineLibrary.PRG:PART,SERIAL,,,,,
            and then I reference them with ......................................here vvvvvvvvvvvvvvvvvv
            Code:
            DIM D14_1= 2D DISTANCE FROM PLANE PLN9 TO CS1:ISUB2[1] PAR TO   ZAXIS,NO_RADIUS  UNITS=IN,$
            GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH
            AX    NOMINAL       +TOL       -TOL       MEAS        DEV     OUTTOL
            M       0.7300     0.0100     0.0100     0.7300     0.0000     0.0000 ----#----
            It all happens in the background I just send a group of mixed features eg vector point, circles, etc oh and variable of non feature types like "hello" (no limit on the quantity) and on the next OP I build them back up automatically. Saves me a bunch of time (mainly cuz I'm lazy).







            To simplify it here's some more of the same code:

            EXPORT (first op1)
            Code:
            $$ NO,
                        _____________________________________________________________________________________________
                        
                        Export data
                        _____________________________________________________________________________________________
                        
                        RECALL/ALIGNMENT,INTERNAL,EXPORT_ALN
                        ASSIGN/ARRAY_1=ARRAY({PNT69},{CIR16},{CIR17})
                        ASSIGN/ARRAY_2=ARRAY({LIN12},{PLN6},{PLN7},{PLN8},{LIN13})
                        ASSIGN/ARRAY_3=ARRAY({LIN14},{PLN9},{PLN10},{PLN11},{LIN15})
                        ASSIGN/ARRAY_4=ARRAY({PNT35},{PNT51})
                        ASSIGN/MULTI_ARRAY=ARRAY(ARRAY_1,ARRAY_2,ARRAY_3,ARRAY_4)
            $$ NO,
                        Push all items in multi dimensional array into a single dimensional array.
                        
                        ASSIGN/SINGLE_ARRAY=0
                        ASSIGN/CNT=1
                        ASSIGN/O_CNT=1
                        DO/
                        ASSIGN/I_CNT=1
                        DO/
                        ASSIGN/SINGLE_ARRAY[CNT]=MULTI_ARRAY[O_CNT,I_CNT]
                        ASSIGN/CNT=CNT+1
                        ASSIGN/I_CNT=I_CNT+1
                        UNTIL/I_CNT > LEN(MULTI_ARRAY[O_CNT])
                        ASSIGN/O_CNT=O_CNT+1
                        UNTIL/O_CNT > LEN(MULTI_ARRAY)
            CS1        =CALLSUB/WRITE_TO_TXT,C:\Users\Public\Documents\WAI\PC-DMIS\2015.1\Subroutines\SubRoutineLibrary.PRG:PART,SERIAL,SINGLE_ARRAY,,,,
                        WORKPLANE/ZPLUS
                        RECALL/ALIGNMENT,INTERNAL,MAIN_ALN
            IMPORT (next op2)
            Code:
            $$ NO,
                        _____________________________________________________________________________________________
                        
                        Import data
                        _____________________________________________________________________________________________
                        (alignment is translated at export so no need to create an 'Import Alingment')
                        
            CS1        =CALLSUB/BUILD_FROM_TXT,C:\Users\Public\Documents\WAI\PC-DMIS\2015.1\Subroutines\SubRoutineLibrary.PRG:PART,SERIAL,,,,,
            Obviously the subroutine program isn't shown as that was built by me but my employer owns it and I don't feel like asking to share their stuff.

            PS.
            I can't believe how much fit in this single post and the forum didn't bark at me "post too long"!

            PS-PS
            Forgot that PcDmis help files are online. Here check out this link towards the bottom you'll find curly bracket material:
            https://docs.hexagonmi.com/pcdmis/20.../Variables.htm
            Last edited by Kp61dude!; 04-27-2021, 04:10 PM.
            PcDmis 2015.1 SP10 CAD++
            Global 7-10-7 DC800S

            Comment


            • Douglas
              Douglas commented
              Editing a comment
              I ran into the line too long recently, bad habit of naming features and variables with long ID... never knew this will definitely use

          • #7
            Originally posted by Kp61dude! View Post

            Those there are pointers to features.
            Example:
            Code:
            ASSIGN/V1={CIR10}
            $$ NO,
            V1.X <-- this is the same as CIR10.X
            This probably has a few different uses.

            The use I was in need of that day was this:

            1. First think of the "line too long" error Pc-Dmis gives you when an assignment that is just too, well, long. To try this create an ASSIGN/V1 = ARRAY(<put something here that's too long>, <to break it>). In my case I had arrays with pointers to features eg. {CIR21} is a pointer to AUTO/FEATURE CIR21 that's a 2D circle.

            2. When it gets too long you have no choice but to break them up into multiple array variables (ASSIGN/V1=ARRAY()). When you do this you'll end up with your data broken up into different variables, not good when your Function only takes one variable array! So, you must take all of your data/variables and combine them into one.

            3. My brain always goes to this thought "hey, just take your variables and combine them into one array!" and I always, I mean always, make the mistake of using this:
            Code:
            ASSIGN/ARRAY_1=ARRAY({PNT69},{CIR16},{CIR17})
            ASSIGN/ARRAY_2=ARRAY({LIN12},{PLN6},{PLN7},{PLN8},{LIN13})
            ASSIGN/ARRAY_3=ARRAY({LIN14},{PLN9},{PLN10},{PLN11},{LIN15})
            ASSIGN/ARRAY_4=ARRAY({PNT35},{PNT51})
            ASSIGN/ARRAY_ALL=ARRAY(ARRAY_1, ARRAY_2, ARRAY_3, ARRAY_4)
            which unfortunately doesn't yield what I expect!!!! It does not give the expected results, you'd think I'd remember what the above does exactly given that I commit this mistake a bunch but, I just don't remember what the above yields I just remember that it doesn't combine all of your arrays into one handy array (too easy, right?!). That is what the original post purpose was crated for... to assist me when my bad memory strikes again! Hopefully I remember that I made this post...
            UPDATE: memory came back.. the above is only parts way done. This creates a multi dimensional array (see original post for making it a single dimensional array).


            Now if you're wondering why I use these 'pointer to features'? Well that's a slightly different story...

            1. In my environment called the workplace and "the way we do things around here!" (imagine a hardcore east-coast mobster accent). We machine parts in multiple ops... sometimes some features will be milled in but will have no datums to measure them to and on the next operation the feature will be inaccessible (great! not great).

            2. What I do (not saying it's the best solution but it's my only goto solution that I thought up and have stuck to)... I measure the said feature export it's characteristics to a text file and then recreate it on the next OP via the builtin generic feature from the characteristics that were read in from the text file.

            3. I am lazy. I hate having to type stuff out over and over and then not to mention what long run maintenance will hinder me. My solution was to create a function with two inputs

            a. array of features and
            b. text file string

            to export. And on the next OP to import I have a function look for a text file that matches ID and part name (that's already in the program for other reasons) and it creates every feature in generic form that I can reference like this:
            first create what will create all the generic features in a subroutine
            Code:
            $$ NO,
            _____________________________________________________________________________________________
            
            Import data
            _____________________________________________________________________________________________
            (alignment is translated at export so no need to create an 'Import Alingment')
            
            CS1 =CALLSUB/BUILD_FROM_TXT,C:\Users\Public\Documents\WAI\PC-DMIS\2015.1\Subroutines\SubRoutineLibrary.PRG:PART,SERIAL,,,,,
            and then I reference them with ......................................here vvvvvvvvvvvvvvvvvv
            Code:
            DIM D14_1= 2D DISTANCE FROM PLANE PLN9 TO CS1:ISUB2[1] PAR TO ZAXIS,NO_RADIUS UNITS=IN,$
            GRAPH=OFF TEXT=OFF MULT=10.00 OUTPUT=BOTH
            AX NOMINAL +TOL -TOL MEAS DEV OUTTOL
            M 0.7300 0.0100 0.0100 0.7300 0.0000 0.0000 ----#----
            It all happens in the background I just send a group of mixed features eg vector point, circles, etc oh and variable of non feature types like "hello" (no limit on the quantity) and on the next OP I build them back up automatically. Saves me a bunch of time (mainly cuz I'm lazy).







            To simplify it here's some more of the same code:

            EXPORT (first op1)
            Code:
            $$ NO,
            _____________________________________________________________________________________________
            
            Export data
            _____________________________________________________________________________________________
            
            RECALL/ALIGNMENT,INTERNAL,EXPORT_ALN
            ASSIGN/ARRAY_1=ARRAY({PNT69},{CIR16},{CIR17})
            ASSIGN/ARRAY_2=ARRAY({LIN12},{PLN6},{PLN7},{PLN8},{LIN13})
            ASSIGN/ARRAY_3=ARRAY({LIN14},{PLN9},{PLN10},{PLN11},{LIN15})
            ASSIGN/ARRAY_4=ARRAY({PNT35},{PNT51})
            ASSIGN/MULTI_ARRAY=ARRAY(ARRAY_1,ARRAY_2,ARRAY_3,ARRAY_4)
            $$ NO,
            Push all items in multi dimensional array into a single dimensional array.
            
            ASSIGN/SINGLE_ARRAY=0
            ASSIGN/CNT=1
            ASSIGN/O_CNT=1
            DO/
            ASSIGN/I_CNT=1
            DO/
            ASSIGN/SINGLE_ARRAY[CNT]=MULTI_ARRAY[O_CNT,I_CNT]
            ASSIGN/CNT=CNT+1
            ASSIGN/I_CNT=I_CNT+1
            UNTIL/I_CNT > LEN(MULTI_ARRAY[O_CNT])
            ASSIGN/O_CNT=O_CNT+1
            UNTIL/O_CNT > LEN(MULTI_ARRAY)
            CS1 =CALLSUB/WRITE_TO_TXT,C:\Users\Public\Documents\WAI\PC-DMIS\2015.1\Subroutines\SubRoutineLibrary.PRG:PART,SERIAL,SINGLE_ARRAY,,,,
            WORKPLANE/ZPLUS
            RECALL/ALIGNMENT,INTERNAL,MAIN_ALN
            IMPORT (next op2)
            Code:
            $$ NO,
            _____________________________________________________________________________________________
            
            Import data
            _____________________________________________________________________________________________
            (alignment is translated at export so no need to create an 'Import Alingment')
            
            CS1 =CALLSUB/BUILD_FROM_TXT,C:\Users\Public\Documents\WAI\PC-DMIS\2015.1\Subroutines\SubRoutineLibrary.PRG:PART,SERIAL,,,,,
            Obviously the subroutine program isn't shown as that was built by me but my employer owns it and I don't feel like asking to share their stuff.

            PS.
            I can't believe how much fit in this single post and the forum didn't bark at me "post too long"!

            PS-PS
            Forgot that PcDmis help files are online. Here check out this link towards the bottom you'll find curly bracket material:
            https://docs.hexagonmi.com/pcdmis/20.../Variables.htm
            Thank you for this, I really appreciate it!

            Comment


            • #8
              Originally posted by DAN_M View Post

              Thank you for this, I really appreciate it!
              Glad to help and hope it made sense.
              PcDmis 2015.1 SP10 CAD++
              Global 7-10-7 DC800S

              Comment


              • #9
                Anytime I think I'm fairly sharp on PCDMIS, all I have to do to dispel that delusion is visit this forum...

                Comment


                • #10
                  Originally posted by Dlmj_1067 View Post
                  Anytime I think I'm fairly sharp on PCDMIS, all I have to do to dispel that delusion is visit this forum...
                  Haha! I bet many of us feel that way. I'm glad there's something to goto to keep me self humble, or else....?
                  Last edited by Kp61dude!; 04-29-2021, 12:43 PM.
                  PcDmis 2015.1 SP10 CAD++
                  Global 7-10-7 DC800S

                  Comment


                  • #11
                    Originally posted by Kp61dude! View Post
                    2. What I do (not saying it's the best solution but it's my only goto solution that I thought up and have stuck to)... I measure the said feature export it's characteristics to a text file and then recreate it on the next OP via the builtin generic feature from the characteristics that were read in from the text file.
                    Great stuff! That is some really fancy measuring routine programming. It sure took a moment for all that to sink in.

                    I sometimes wish PC-DMIS had some way to concatenate arrays the way you can with strings.

                    A few times now I have ended up trying something like this and then get reminded that it just doesn't work:
                    ASSIGN/SARY[1..LEN(ARY1)]=ARY1

                    When it comes to exporting the features characteristics, are you just exporting the names, coordinates, and vectors, or is there more to it than that? I don't suppose you can write a whole object to a text file.

                    Comment


                    • #12
                      Cris_C don't say I've never given you anything...

                      Code:
                      $$ NO,
                                  _____________________________________________________________________________________________
                                   
                                                               Export OP20 data to .txt for OP30.
                                  _____________________________________________________________________________________________
                                   
                                  Updated By: Kp61dude!
                                  Updated on: 20190820
                                  Update Reason: 'GETTEXT()' does not pull any information from Generic Features. I found a solution
                                                 to get this missing information. 'GETTEXT()' is doing the job of gathering this info
                                                 but again it doesn't for Generic types, the workaround is '.FTYPE' (returns INTEGER value of
                                                 feature type from a predefined PcDmis list, see PCD help). 
                                                 'MY_FTYPE' is loaded with, previously missing, string information (ie. "PLANE", "CIRCLE").
                                                 Logic 'If/LEN(MY_FTYPE) <= 0' was added and 'FTYPE' was changed to 'MY_FTYPE'.
                                   
                                  Update on: 20200427
                                  Update Reason: Added "CYLINDER" to CASE
                                   
                                  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),
                                      APPEND = 0 : APPEND TO EXISTING FILE,
                                       = 
                                  ASSIGN/DEBUG=0
                                  ASSIGN/SERNUM=RIGHT(SERIAL,LEN(SERIAL)-INDEX(SERIAL,"-"))
                                  ASSIGN/TXTFILE1="C:\USERS\PUBLIC\DOCUMENTS\WAI\PC-DMIS\2015.1\PN_"+PART+"_SN_"+SERNUM+".txt"
                      $$ NO,
                                   
                                   
                                  IF/APPEND
                      FPTR         =FILE/OPEN,TXTFILE1,APPEND
                                  END_IF/
                                  ELSE/
                      FPTR         =FILE/OPEN,TXTFILE1,WRITE
                                  END_ELSE/
                      $$ NO,
                                   
                                   
                                  IF/DEBUG
                                    ASSIGN/LOG_FILE="c:\users\public\documents\wai\pc-dmis\2015.1\DEBUG_LOG.txt"
                      DEBUGLOG     =FILE/OPEN,LOG_FILE,APPEND
                                    FILE/WRITELINE,DEBUGLOG,"*********************************************"
                                    FILE/WRITELINE,DEBUGLOG,"Started: " + SYSTEMTIME("hh:mm:ss tt") + ", " + SYSTEMDATE("MM'/'dd'/'yyyy")
                                  END_IF/
                      $$ NO,
                                   
                                   
                                  DO/
                                  ASSIGN/COUNTER=COUNTER+1
                                  ASSIGN/MY_FTYPE=GETTEXT(486,0,FNAME[COUNTER]) + GETTEXT(63,0,FNAME[COUNTER])
                                  ASSIGN/MY_FTYPE=GETTEXT(486,0,MY_FTYPE) + GETTEXT(63,0,MY_FTYPE)
                                  IF/LEN(MY_FTYPE) <= 0
                                    SELECT/FNAME[COUNTER].FTYPE
                                      CASE/1
                                        ASSIGN/MY_FTYPE=""
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". MY_FTYPE IS NULL " + MY_FTYPE
                                        END_IF/
                                      END_CASE/
                                      CASE/2
                                        ASSIGN/MY_FTYPE="CIRCLE"
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". MY_FTYPE IS CIRCLE " + MY_FTYPE
                                        END_IF/
                                      END_CASE/
                                      CASE/4
                                        ASSIGN/MY_FTYPE="LINE"
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". MY_FTYPE IS LINE " + MY_FTYPE
                                        END_IF/
                                      END_CASE/
                                      CASE/6
                                        ASSIGN/MY_FTYPE="CYLINDER"
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". MY_FTYPE is CYLINDER " + MY_FTYPE
                                        END_IF/
                                      END_CASE/
                                      CASE/7
                                        ASSIGN/MY_FTYPE="PLANE"
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". MY_FTYPE is PLANE " + MY_FTYPE
                                        END_IF/
                                      END_CASE/
                                      DEFAULT_CASE/
                                        ASSIGN/MY_FTYPE=""
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". MY_FTYPE is null and DEFAULT " + MY_FTYPE
                                        END_IF/
                                      END_DEFAULTCASE/
                                    END_SELECT/
                                  END_IF/
                                  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/MY_FTYPE
                                      CASE/"CIRCLE"
                                        FILE/WRITELINE,FPTR,"CIRCLE"+FNAME[COUNTER].XYZ +";"+ FNAME[COUNTER].IJK +";"+ FNAME[COUNTER].D
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". Wrote CIRCLE"
                                        END_IF/
                                      END_CASE/
                                      CASE/"CYLINDER"
                                        FILE/WRITELINE,FPTR,"CYLINDER"+FNAME[COUNTER].XYZ +";"+ FNAME[COUNTER].IJK +";"+ FNAME[COUNTER].D +";"+ FNAME[COUNTER].L
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". Wrote CYLINDER"
                                        END_IF/
                                      END_CASE/
                                      CASE/"PLANE"
                                        FILE/WRITELINE,FPTR,"PLANE"+FNAME[COUNTER].XYZ +";"+ FNAME[COUNTER].IJK
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". Wrote PLANE"
                                        END_IF/
                                      END_CASE/
                                      CASE/"LINE"
                                        FILE/WRITELINE,FPTR,"LINE"+FNAME[COUNTER].XYZ +";"+ FNAME[COUNTER].IJK+";"+FNAME[COUNTER].LENGTH
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". Wrote LINE"
                                        END_IF/
                                      END_CASE/
                                      DEFAULT_CASE/
                                        FILE/WRITELINE,FPTR,FNAME[COUNTER].XYZ +";"+ FNAME[COUNTER].IJK
                                        IF/DEBUG
                                          FILE/WRITELINE,DEBUGLOG,COUNTER + ". Wrote DEFAULT (POINT)"
                                        END_IF/
                                      END_DEFAULTCASE/
                                    END_SELECT/
                                  END_ELSE/
                                  IF/!FNAME.LEN==COUNTER
                                    ASSIGN/RETURN=RETURN + MY_FTYPE + " "
                                  END_IF/
                                  ASSIGN/MY_FTYPE=""
                                  UNTIL/COUNTER==LEN(FNAME)
                      $$ NO,
                                   
                                   
                                  FILE/CLOSE,FPTR,KEEP
                                  IF/DEBUG
                                    FILE/WRITELINE,DEBUGLOG,"*********************************************"
                                    FILE/CLOSE,DEBUGLOG,KEEP
                                  END_IF/
                                  ENDSUB/
                      PcDmis 2015.1 SP10 CAD++
                      Global 7-10-7 DC800S

                      Comment


                      • #13
                        Code:
                        $$ NO,
                                    _____________________________________________________________________________________________
                                     
                                                                     Import OP20 data and build.
                                    _____________________________________________________________________________________________
                                                 For more instructions on how to dimension features on main program that are built here
                                                 see: 'IDs for features within subroutines, basic scripts, or external routines'
                                                 in the PcD Help Files.
                                     
                                     
                                               To dimension feature 'ISUB1/2/3/etc.'(created in sub) use "<Call Sub ID>:<FeatID>" ex..
                                      
                                    In your main program it may look like something like this:
                                    (Use [n] after the call in case of multiple features, most likely the case for this one.)
                                     
                                                                      here vvv
                                    DIM LOC1= LOCATION OF POINT CS1:FRMSUB1[1]  UNITS=IN ,$
                                    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
                                    AX    NOMINAL       +TOL       -TOL       MEAS        DEV     OUTTOL
                                    X       0.9012   100.0000   100.0000     0.9012     0.0000     0.0000 ----#-----
                                    END OF DIMENSION LOC1
                                     
                                     AND to create constructed data ex...(circle from 8 points)
                                     
                                    CIR1       =FEAT/CIRCLE,CARTESIAN,IN,LEAST_SQR,NO
                                                THEO/<0,0,0>,<0,0,1>,2.0615
                                                ACTL/<0,0,0>,<0,0,1>,2.0615
                                                CONSTR/CIRCLE,BF,2D,CS1:ISUB1[1],CS1:ISUB1[2],CS1:ISUB1[3],CS1:ISUB1[4],CS1:ISUB1[5],CS1:ISUB1[6],CS1:ISUB1[7],CS1:ISUB1[8],,
                                                OUTLIER_REMOVAL/OFF,3
                                                FILTER/OFF,UPR=0
                                     
                                    If passing variables: load as many as you wish when using 'WRITE_TO_TEXT', this routine will return them all in RETUNVALS as an array type.
                                    ex...
                                        'RETURNVALS[1]'
                                        'RETURNVALS[2]'
                                        'RETURNVALS[3]'
                                        'RETURNVALS[4]'
                                    and so on.
                                    ____________________________________________________________________________________________
                                    SUBROUTINE/BUILD_FROM_TXT,
                                        PART =  : INPUT; ROUTINES PART#,
                                        SERIAL =  : INPUT; STRING OF TEXT FLOWED DOWN FROM PLC,
                                        RETURN =  : OPTIONAL OUTPUT: STATUS MESSAGE,
                                        DELYN = 1 : OPTIONAL INPUT: DELETE OR KEEP TXT FILE; DEFAULT AS DELETE,
                                        RETURNVALS =  : OPTIONAL OUTPUT: PASS OP20 VAR DATA,
                                         = 
                                    ASSIGN/SERNUM_OLD=RIGHT(SERIAL,LEN(SERIAL)-INDEX(SERIAL,"-"))
                                    ASSIGN/SERNUM=ELEMENT(2,"-",SERIAL)
                                    ASSIGN/IFN="C:\Users\Public\Documents\WAI\PC-DMIS\2015.1\PN_"+PART+"_SN_"+SERNUM+".txt"
                        FILEYN     =FILE/EXISTS,IFN
                                    IF/FILEYN
                        FPTR         =FILE/OPEN,IFN,READ
                                      ASSIGN/I=0
                                    DO/
                                    ASSIGN/I=I+1
                                    ASSIGN/DD="D"+I
                                    ASSIGN/TYP=""
                        L1         =FILE/READLINE,FPTR,{typ}+"<"+{dd.x}+","+{dd.y}+","+{dd.z}+">;<"+{dd.i}+","+{dd.j}+","+{dd.k}+">;"+{dd.d}+";"+{dd.l}
                                    IF/!L1=="EOF"
                                      SELECT/TYP
                                        CASE/"CIRCLE"
                        ISUB2            =GENERIC/CIRCLE,DEPENDENT,CARTESIAN,OUT,$
                                          NOM/XYZ,<DD.X,DD.Y,DD.Z>,$
                                          MEAS/XYZ,<DD.X,DD.Y,DD.Z>,$
                                          NOM/IJK,<DD.I,DD.J,DD.K>,$
                                          MEAS/IJK,<DD.I,DD.J,DD.K>,$
                                          DIAMETER/DD.D,DD.D
                                        END_CASE/
                                        CASE/"CYLINDER"
                        ISUB4            =GENERIC/CYLINDER,DEPENDENT,CARTESIAN,OUT,$
                                          NOM/XYZ,<DD.X,DD.Y,DD.Z>,$
                                          MEAS/XYZ,<DD.X,DD.Y,DD.Z>,$
                                          NOM/IJK,<DD.I,DD.J,DD.K>,$
                                          MEAS/IJK,<DD.I,DD.J,DD.K>,$
                                          DIAMETER/DD.D,DD.D,$
                                          DISTANCE/DD.L,DD.L
                                        END_CASE/
                                        CASE/"PLANE"
                        ISUB3            =GENERIC/PLANE,DEPENDENT,CARTESIAN,$
                                          NOM/XYZ,<DD.X,DD.Y,DD.Z>,$
                                          MEAS/XYZ,<DD.X,DD.Y,DD.Z>,$
                                          NOM/IJK,<DD.I,DD.J,DD.K>,$
                                          MEAS/IJK,<DD.I,DD.J,DD.K>
                                        END_CASE/
                                        CASE/"LINE"
                        ISUB5            =GENERIC/LINE,DEPENDENT,CARTESIAN,$
                                          NOM/XYZ,<DD.X,DD.Y,DD.Z>,$
                                          MEAS/XYZ,<DD.X,DD.Y,DD.Z>,$
                                          NOM/IJK,<DD.I,DD.J,DD.K>,$
                                          MEAS/IJK,<DD.I,DD.J,DD.K>,$
                                          DISTANCE/DD.D,DD.D
                                        END_CASE/
                                        CASE/"VAR"
                                          ASSIGN/VARCOUNTER=VARCOUNTER+1
                                          ASSIGN/HITS[VARCOUNTER]=I
                                          ASSIGN/VARARRAY[I]=LEFT(DD.X,LEN(DD.X)-1)
                                        END_CASE/
                                        DEFAULT_CASE/
                        ISUB1            =GENERIC/POINT,DEPENDENT,CARTESIAN,$
                                          NOM/XYZ,<DD.X,DD.Y,DD.Z>,$
                                          MEAS/XYZ,<DD.X,DD.Y,DD.Z>,$
                                          NOM/IJK,<DD.I,DD.J,DD.K>,$
                                          MEAS/IJK,<DD.I,DD.J,DD.K>
                                        END_DEFAULTCASE/
                                      END_SELECT/
                                    END_IF/
                                    UNTIL/L1=="EOF"
                                    IF/DELYN
                                      FILE/CLOSE,FPTR,DELETE
                                    END_IF/
                                    ELSE/
                                      FILE/CLOSE,FPTR,KEEP
                                    END_ELSE/
                                    END_IF/
                                    ASSIGN/T=VARCOUNTER
                                    ASSIGN/U=0
                                    IF/!T==0
                                    DO/
                                    ASSIGN/U=U+1
                                    ASSIGN/VALS[U]=VARARRAY[HITS[U]]
                                    UNTIL/U==T
                                    END_IF/
                                    ASSIGN/RETURNVALS=VALS
                                    ASSIGN/RETURN=IF(FILEYN,IFN +",  File found.",IFN +",  File not found.")
                                    ENDSUB/
                        PcDmis 2015.1 SP10 CAD++
                        Global 7-10-7 DC800S

                        Comment


                        • #14
                          Originally posted by Kp61dude! View Post
                          Cris_C don't say I've never given you anything...
                          Holy Cow!

                          I did not expect that! Thanks man. You rule!

                          I've got a lot of close code reading and head scratching in my near future.

                          Comment


                          • Kp61dude!
                            Kp61dude! commented
                            Editing a comment
                            you'll drill into it and realize its not that complicated...

                        • #15
                          above code can be cleaned up substantially but the meat and potatoes are there for ya'll to improve on. Happy coding!
                          PcDmis 2015.1 SP10 CAD++
                          Global 7-10-7 DC800S

                          Comment

                          Related Topics

                          Collapse

                          Working...
                          X