Matrix handling Python API

No, you recreate the text file in “cadinp” code.

Basically you make python generate the following cadinp command in a text file (call it py.txt):
if (row==0)
Let#list 35,64,85,48
elseif (row==1)
Let#list 12,53,81,1
elseif (row==2)
Let#list 10,55,99,2
endif

And now you can simplify your teddy code to:
Loop#row 3
#Include py.txt $ This pastes the above text and the if construct defines list to be the chosen row
Loop#node 4
Node No #node type wyy #list(#node)
EndLoop
EndLoop

In case you noticed, I started the “rowcounter” at zero to correspond with the loopvariabel.
Makes the code prettier :grin:

Basically you have pasted the entire if construct into the code and for every loop you are redefining your #list variable to correspond to the correct row.

Your gut reaction to try and define several variables with numbers (list1, list2, list3) or text files (list1.txt, list2.txt, list3.txt) is easily implemented in python, C++, etc.
In cadinp this approach is hard since there is no string manipulation of variables (i.e. you cannot generate let#listxx on the fly without a lot of workarounds)

Also the #include works similar to preprocessor directives in C or C++. The calculation program (wps.exe.) parses your teddy file and literally pastes the block/text at the include insertion point.
You can see this if you check the report and turn on the cadinp code.

1 Like