Apply loads by array


Is it possible to apply loads using arrays without having to use loops?

Please see my small example code below:

+prog aqua urs:35.1
    head Materials
    MAT 1 E 35000 mue 0.3 gam 25
    SREC 1 H 1000[mm] B 500[mm] MNO 1

+prog sofimshc urs:35.2
    head Geometry
    UNIT 5

    loop#i 10
        SPT #i+1 X #i*2000[mm] Y 0

    loop#i 9
        SLN #i+1 NPA #i+1 NPE #i+2 SNO 1 GRP #i+1

    SPT -1 fix pp
    SPT -10 fix pp

+prog sofiload urs:35.3
    head Load
        let#mygrp 1,2,3,4

        LC 1 TYPE 'NONE'
                LINE REF BGRP #mygrp PROJ YY WIDE 10  P1 10 X1  0 Y1 5[m] $$
                                                            X2 10[m] Y2 5[m]


Here I’d like to apply loads to #mygrp I have tried multiple variations e.g. #mygrp(:) (#mygrp(0 3 1)) etc. but nothing works.

I figured out that this can be done by using $ variables instead of #. As such, a string containing the exact text from the $ variable is input.

Thereby, the sofiload program looks like this instead:

+prog sofiload
    head Load
        #define mygrp=1,2,3,4

        LC 1 TYPE 'NONE'
                LINE REF BGRP $(mygrp) PROJ YY WIDE 10  P1 10 X1 0[m]  Y1 5[m] $$
                                                              X2 10[m] Y2 5[m]

This however, leads to another problem.
I can’t have the $ variable hardcoded and I need to define it through a loop.

As per the manual §2.9.1:

Definitions like $(A$(INDEX)) are allowed

But I can’t for the life of me get indexing to work.

So… How do I define a $ variable in a loop?

why dont u want to use loops? maybe try use array length as count of loops

 +prog sofiload
 head loads
 let#mygrp 1,2,3,4
 lc 1 none
   loop#i mygrp
     line ref bgrp #mygrp(#i) proj yy wide 10 p1 10 x1 0[m] y1 5[m] x2 10[m] y2 5[m] 

Loops are ineffective and should be avoided when possible to limit computational time and improve readability (this is not just a sofistik thing, but general for all programming)

In this case, since it’s possible to write ... bgrp 1,2,3,4 proj yy... it should also be possible to input it with an array.

does your loop have a noticeable execution time? if not, look for optimization of computing time elsewhere, and if so, I do not know the solution :slight_smile: based on my observation, the list of values as a parameter is turned into a loop anyway.