Python script loadrecord.fromtext

Python script loadrecord.fromtext

1234eddie
Advocate Advocate
702 Views
3 Replies
Message 1 of 4

Python script loadrecord.fromtext

1234eddie
Advocate
Advocate

Hi all,

As autodesk has stopped supporting dynamo studio, i have to tranfser my scripts to dynamo inside Robot Structural Analysis 2022.
The base part of my script is working. but i have a list that the script reads wrong.
this is the list as input.

1234eddie_0-1648543105688.jpeg
this is the first edit i do. 'take a string from the list at index 0

1234eddie_1-1648543105713.jpeg

then in row 272 with dynamo studio 2017 the values where set to the whole list. but now it only works on 1.

1234eddie_2-1648543105969.jpeg

This should be the result.

1234eddie_3-1648543105719.jpeg
and this is what i get now.
1234eddie_4-1648543105725.jpeg
 

I guess it’s probably some easy steps to take but for me it quite annoying at the moment.

 

Hope someone of you can explain me why this is happening?

 

@Rafal.Gaweda @JacquesGaudin 

 

Thanks in advance.

Gr Edward

703 Views
3 Replies
Replies (3)
Message 2 of 4

JacquesGaudin
Advocate
Advocate

Hi @1234eddie,

 

`stap[0]` is the first element of the list so an integer. Casting it to a string gives a string like '2' for example. If you want all the elements in a string you can do:

 

 

loadnodes = str(stap).replace('[', '').replace(']', '').replace(',', ' ')

 

 

or if you'd rather:

 

loadnodes = ' '.join(str(el) for el in stap)

 

 

which will generate a string like: '1 2 3 4' if the list is [1, 2, 3, 4]

0 Likes
Message 3 of 4

1234eddie
Advocate
Advocate

@JacquesGaudin 

 

thanks for your reaction. at the moment i can't get your solution to work.

for now i'm just using 

loadnodes = ('1 201 401 601 801')

 hopefully i find i solution when transferring from ironpython2 to Cpyhton3.

 

thanks.

0 Likes
Message 4 of 4

JacquesGaudin
Advocate
Advocate

Strange... Do you have an error message? What is the content of your variable `stap` when this part of the script is reached?

It looks like the variable may contain a list of lists from the screenshot but hard to tell without seeing more.

0 Likes