Open and read from .str file using Python

Open and read from .str file using Python

Mouhammad_mazzaz
Advocate Advocate
1,791 Views
8 Replies
Message 1 of 9

Open and read from .str file using Python

Mouhammad_mazzaz
Advocate
Advocate

Hi,

can someone help me, I am trying to extract some data from the str file using python 
the thing is that I am able to read the data and print it but I can not search for the data using the line.startswith 

how to deal with .str using python 

this is a small example not the full code 

with open(SourceFile,"r") as file: # where SourceFile = Structure.str
    for line in file:
        if line.startswith(" NODes \n"😞 # search for a keyword
            printing = True
            continue # go to next line
        elif line.startswith(" ;CON"😞
            printing = False
            break #quit file reading
        if printing:
            print(line, file=PointsFile) # where PointsFile = a txt file to save the extracted points data to it
PointsFile.close()
0 Likes
Accepted solutions (3)
1,792 Views
8 Replies
Replies (8)
Message 2 of 9

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @Mouhammad_mazzaz 

I imagine you want to use the *.str files to perform outside non-running reads outside of Robot otherwise you can use the API.

At first glance, yes for reading nodes, for a start and a code used once, why not.

Only the first three letters are enough and they vary depending on the language.

For the startwith function you could replace it with contains + 3 letter code.

To stop, the "CON" code of the contours is not always the one following the nodes but any code can interrupt the previous one including END at the end of the file.

Nodes may also contain variable pitch repeat codes and are not always a contiguous list of coordinates, there may be also line breaks. So, you need to create a file reading pattern depending on the active code used.

https://forums.autodesk.com/t5/robot-structural-analysis-forum/str-reference-manual/td-p/3191542

Best regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 3 of 9

Mouhammad_mazzaz
Advocate
Advocate
Hi @Stephane.kapetanovic
Thanks for the reply, Thats helps me alot.
I was actually asking myself that question does the node ends by the contour line every time
so what do you think the best way to transfer the model from robot to other software such as CSI ETABS
let's say the user does not have a license for RSA, and he reviced the concept model as an rtd and str files
and he need to develop the SD or the DD model (schematic or detailed design ) using other software
then the only way is using a tool reads the elements from the str file
I know it could be a lot information missing but it is still better than starting modeling from zero
and believe me it does specially if you have a huge model
0 Likes
Message 4 of 9

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @Mouhammad_mazzaz 

Given the anteriority of this software and the skills of the expert people present on this forum and beyond, it is more than likely that this conversion already exists for many of us in different forms. Note that you can use VB, C#, Python to name only the most popular.

Best regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 5 of 9

Mouhammad_mazzaz
Advocate
Advocate

Unfortunate there is no such a tool, I've searched and I found only 1 tool and it is quite expensive.

  So I tried to do something similer using python and C#

  Anyway lets hope one of the experts will reply on this topic

0 Likes
Message 6 of 9

Romanich
Mentor
Mentor

Hi @Mouhammad_mazzaz ,

Are you talking about Geometry Gym?

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.

Roman Zhelezniak

Robot Evangelist & Passionate Civil Structural Engineer

LinkedIn | Robot & Хобот | App Store for Robot
EESignature


Message 7 of 9

Mouhammad_mazzaz
Advocate
Advocate
Hi Romanich,
No It was a tool I saw it in youtube video, but I think Geometry Gym does not have a tool to convert between robot and etabs direct,

I think the only way it can be done through grasshopper, robot to grasshopper then grasshopper to Etabs.
which can be done through the revit
ROBOT TO REVIT then REVIT TO CSI ETABS

I am trying to find a solution for those does not have a robot or they do not know how to work on robot

and I am struggling here with the options.

I've learned some basic in C# and python and I need to work on a real examples so I can implement my programming skills into my work

I would love to share any thing with me .

Thanks in advance
0 Likes
Message 8 of 9

JacquesGaudin
Advocate
Advocate
Accepted solution

Hi @Mouhammad_mazzaz ,

 

Have you considered exporting the robot model geometry as a dxf file and import it in other softwares?

I found that parsing text files is like opening a can of worms: the code is usually complex, bug-prone and hard to maintain.

Using the dxf export may save you a few headaches. 

 

If you have a good reason to parse str files yourself, you would need to use `while` loops to loop over the various sections of the str file to extract the relevant information.

 

Jacques

0 Likes
Message 9 of 9

Mouhammad_mazzaz
Advocate
Advocate
DXF will export the geometry only.
0 Likes