hexagon logo

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!).

            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.
Parents

  • 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.
Reply

  • 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.
Children
No Data