Python Forum
Python for syntax conversion
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python for syntax conversion
#12
(Dec-23-2019, 05:13 PM)Gribouillis Wrote: These classes are empty for now but you will be free to add features to them later.

It would be a good idea to include an example of a typical input file if you can do that.

There is an obstacle again. I would like to deal with the materials first.
Here are the material statement in a software.

TABLE: "MATERIAL PROPERTIES 01 - GENERAL"
Material=4000Psi Type=Concrete SymType=Isotropic TempDepend=No Color=Magenta Notes="Customary f'c 4000 psi 23/12/2019 2:17:43 pm"
Material=A615Gr60 Type=Rebar SymType=Uniaxial TempDepend=No Color=White Notes="ASTM A615 Grade 60 23/12/2019 2:18:28 pm"
Material=A992Fy50 Type=Steel SymType=Isotropic TempDepend=No Color=Red Notes="ASTM A992 Grade 50 23/12/2019 2:17:43 pm"
Material=C30 Type=Concrete SymType=Isotropic TempDepend=No Color=Blue Notes="Concrete added 23/12/2019 2:18:37 pm"
Material=C45 Type=Concrete SymType=Isotropic TempDepend=No Color=Blue Notes="Concrete added 23/12/2019 2:20:37 pm"
Material=C60 Type=Concrete SymType=Isotropic TempDepend=No Color=Blue Notes="Concrete added 23/12/2019 2:21:13 pm"

TABLE: "MATERIAL PROPERTIES 02 - BASIC MECHANICAL PROPERTIES"
Material=4000Psi UnitWeight=2.40276966513304E-06 UnitMass=2.45014307299925E-10 E1=2534.56354148831 G12=1056.0681422868 U12=0.2 A1=0.0000099
Material=A615Gr60 UnitWeight=7.84904757236607E-06 UnitMass=8.0038007068661E-10 E1=20389.0191580383 A1=0.0000117
Material=A992Fy50 UnitWeight=7.84904757236607E-06 UnitMass=8.0038007068661E-10 E1=20389.0191580383 G12=7841.93044539935 U12=0.3 A1=0.0000117
Material=C30 UnitWeight=2.49830467094493E-06 UnitMass=2.54756172606745E-10 E1=2263.76994673377 G12=943.237477805739 U12=0.2 A1=0.0000099
Material=C45 UnitWeight=2.49830467094493E-06 UnitMass=2.54756172606745E-10 E1=2692.05074746719 G12=1121.68781144466 U12=0.2 A1=0.0000099
Material=C60 UnitWeight=2.49830467094493E-06 UnitMass=2.54756172606745E-10 E1=3059.14857666726 G12=1274.64524027803 U12=0.2 A1=0.0000099

The first three materials are default inside the software so I would not extract the information inside it. Also, a same material has divided into two table so I would like to deal with 'material properties 01' first.

SAP = open('Frame SAP.$2k', 'r')

#Using the 'class' for the material statement 01
class SAP_Material_Statement01:
    def __init__(self, Name, Type, Symtype, Tempdepend, Colour, Notes):
        self.Name = Name
        self.Type = Type
        self.Symtype= Symtype
        self.Tempdepend = Tempdepend
        self.Colour = Colour
        self.Notes = Notes

    def __repr__(self):
        return '{}(   Material={}   Type={}   SymType={}   TempDepend={}   Color={}   Notes="{}")'.format(self.__class__.__name__, self.Name, self.Type, self.Symtype, self.Tempdepend, self.Colour, self.Notes)

#Try to apply the things in it and see whether it is same as the statement inside the file
test = SAP_Material_Statement01('C30', 'Concrete', 'Isotropic', 'No', 'Blue', 'Concrete added 23/12/2019 2:18:37 pm')
#print(test)

#empty class (In fact, I dont know how to use it)
class material_(SAP_Material_Statement01):
    pass

#Since there are many other kinds of statements, so I would like to extract the things in material prop 01
SAP_material_statement_01 = []
for line in SAP:
    split_01 = line.split('=')     #From the above statement, it start with Material=C30 with 3 space bar infront of it
    #print(split_01)               #Thus, I should split the '='
    split_02 = line.split('   ')   #Since I am dealing with material prop 01, the TempDepend is always =No in the majority cases
    #print(split_02)               #Thus, I split the '   ' and use TempDepend=No for an indication to let me extract the things only in material prop 01
    if split_01[0] == '   Material' and split_02[4] == 'TempDepend=No':
        SAP_material_statement_01.append(line)
print(SAP_material_statement_01)
for line in SAP_material_statement_01:
    print(line.split())
[Image: 4sGzbKT]
I have stopped in this step. I need all the things after '=' (e.g. C30, Concrete, Isotropic).
However, I do not know the next step
Reply


Messages In This Thread
Python for syntax conversion - by kingsman - Dec-20-2019, 02:52 PM
RE: Python for syntax conversion - by ichabod801 - Dec-20-2019, 03:58 PM
RE: Python for syntax conversion - by kingsman - Dec-20-2019, 05:33 PM
RE: Python for syntax conversion - by Gribouillis - Dec-20-2019, 06:59 PM
RE: Python for syntax conversion - by kingsman - Dec-21-2019, 04:49 PM
RE: Python for syntax conversion - by Gribouillis - Dec-21-2019, 05:16 PM
RE: Python for syntax conversion - by kingsman - Dec-22-2019, 10:02 AM
RE: Python for syntax conversion - by buran - Dec-21-2019, 05:47 PM
RE: Python for syntax conversion - by Gribouillis - Dec-22-2019, 10:58 AM
RE: Python for syntax conversion - by kingsman - Dec-23-2019, 04:44 PM
RE: Python for syntax conversion - by Gribouillis - Dec-23-2019, 05:13 PM
RE: Python for syntax conversion - by kingsman - Dec-24-2019, 11:55 AM
RE: Python for syntax conversion - by Gribouillis - Dec-24-2019, 01:03 PM
RE: Python for syntax conversion - by kingsman - Dec-26-2019, 12:48 PM
RE: Python for syntax conversion - by Gribouillis - Dec-26-2019, 05:50 PM
RE: Python for syntax conversion - by kingsman - Dec-27-2019, 01:07 PM
RE: Python for syntax conversion - by Gribouillis - Dec-27-2019, 01:47 PM
RE: Python for syntax conversion - by kingsman - Dec-27-2019, 02:05 PM
RE: Python for syntax conversion - by Gribouillis - Dec-27-2019, 02:15 PM
RE: Python for syntax conversion - by kingsman - Dec-27-2019, 03:49 PM
RE: Python for syntax conversion - by kingsman - Apr-27-2020, 09:26 AM
RE: Python for syntax conversion - by Gribouillis - Dec-27-2019, 04:18 PM
RE: Python for syntax conversion - by kingsman - Dec-27-2019, 04:26 PM
RE: Python for syntax conversion - by kingsman - Apr-27-2020, 03:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python format conversion bluefrog 2 2,790 Jul-22-2018, 03:49 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020