Skip to content

Commit 37d20eb

Browse files
committed
changes in ifc2ca standard case
1 parent dd6912b commit 37d20eb

4 files changed

Lines changed: 75 additions & 69 deletions

File tree

src/ifc2ca/ca2ifc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def convert(self):
9494
)
9595
ifcMaterialProfileSets = [None for _ in range(len(mpSets))]
9696
for i, mpSet in enumerate(mpSets):
97-
materialIndex = [mat["ifcName"] for mat in self.data["db"]["materials"]].index(mpSet.split("-")[0])
98-
profileIndex = [prof["ifcName"] for prof in self.data["db"]["profiles"]].index(mpSet.split("-")[1])
97+
materialIndex = [mat["referenceName"] for mat in self.data["db"]["materials"]].index(mpSet.split("-")[0])
98+
profileIndex = [prof["referenceName"] for prof in self.data["db"]["profiles"]].index(mpSet.split("-")[1])
9999
material = ifcMaterials[materialIndex]
100100
profile = ifcProfiles[profileIndex]
101101
matProf = self.f.createIfcMaterialProfile(
@@ -218,7 +218,7 @@ def convert(self):
218218
for i, mat in enumerate(self.data["db"]["materials"]):
219219
groupOfElements = []
220220
for j, el in enumerate(self.data["elements"]):
221-
if el["geometryType"] == "surface" and el["material"] == mat["ifcName"]:
221+
if el["geometryType"] == "surface" and el["material"] == mat["referenceName"]:
222222
groupOfElements.append(ifcElements[j])
223223
if groupOfElements:
224224
self.f.createIfcRelAssociatesMaterial(
@@ -228,7 +228,7 @@ def convert(self):
228228
# create connections with elements
229229
for i, el in enumerate(self.data["elements"]):
230230
for conn in el["connections"]:
231-
j = [c["ifcName"] for c in self.data["connections"]].index(conn["relatedConnection"])
231+
j = [c["referenceName"] for c in self.data["connections"]].index(conn["relatedConnection"])
232232
geometryType = self.data["connections"][j]["geometryType"]
233233

234234
if conn["appliedCondition"]:

src/ifc2ca/ifc2ca.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def convert(self):
4646
id = int(mat.split("|")[1])
4747
material = self.get_material_properties(self.file.by_id(id))
4848
material["relatedElements"] = [
49-
e["ifcName"]
49+
e["referenceName"]
5050
for e in elements
5151
if "material" in e and e["material"] == mat
5252
]
@@ -60,14 +60,14 @@ def convert(self):
6060
id = int(prof.split("|")[1])
6161
profile = self.get_profile_properties(self.file.by_id(id))
6262
profile["relatedElements"] = [
63-
e["ifcName"]
63+
e["referenceName"]
6464
for e in elements
6565
if "profile" in e and e["profile"] == prof
6666
]
6767
profiledb.append(profile)
6868

6969
self.result = {
70-
"ifcName": model.is_a() + "|" + str(model.id()),
70+
"referenceName": model.is_a() + "|" + str(model.id()),
7171
"name": model.Name,
7272
"id": model.GlobalId,
7373
"elements": elements,
@@ -157,7 +157,7 @@ def get_item_data(self, item):
157157
)
158158

159159
return {
160-
"ifcName": f"{item.is_a()}|{item.id()}",
160+
"referenceName": f"{item.is_a()}|{item.id()}",
161161
"name": item.Name,
162162
"id": item.GlobalId,
163163
"geometryType": "line",
@@ -200,7 +200,7 @@ def get_item_data(self, item):
200200
)
201201

202202
return {
203-
"ifcName": f"{item.is_a()}|{item.id()}",
203+
"referenceName": f"{item.is_a()}|{item.id()}",
204204
"name": item.Name,
205205
"id": item.GlobalId,
206206
"geometryType": "surface",
@@ -231,7 +231,7 @@ def get_item_data(self, item):
231231
)
232232

233233
return {
234-
"ifcName": f"{item.is_a()}|{item.id()}",
234+
"referenceName": f"{item.is_a()}|{item.id()}",
235235
"name": item.Name,
236236
"id": item.GlobalId,
237237
"geometryType": "point",
@@ -262,7 +262,7 @@ def get_item_data(self, item):
262262
)
263263

264264
return {
265-
"ifcName": f"{item.is_a()}|{item.id()}",
265+
"referenceName": f"{item.is_a()}|{item.id()}",
266266
"name": item.Name,
267267
"id": item.GlobalId,
268268
"geometryType": "line",
@@ -460,7 +460,7 @@ def get_material_properties(self, material):
460460
commonProps = self.get_pset_properties(psets, None)
461461

462462
return {
463-
"ifcName": material.is_a() + "|" + str(material.id()),
463+
"referenceName": material.is_a() + "|" + str(material.id()),
464464
"name": material.Name,
465465
"category": material.Category,
466466
"mechProps": mechProps,
@@ -486,7 +486,7 @@ def get_pset_properties(self, psets, pset_name):
486486
def get_profile_properties(self, profile):
487487
if profile.is_a("IfcRectangleProfileDef"):
488488
return {
489-
"ifcName": profile.is_a() + "|" + str(profile.id()),
489+
"referenceName": profile.is_a() + "|" + str(profile.id()),
490490
"profileName": profile.ProfileName,
491491
"profileType": profile.ProfileType,
492492
"profileShape": "rectangular",
@@ -503,7 +503,7 @@ def get_profile_properties(self, profile):
503503
mechProps = self.get_i_section_properties(profile, "iSymmetrical")
504504

505505
return {
506-
"ifcName": f"{profile.is_a()}|{profile.id()}",
506+
"referenceName": f"{profile.is_a()}|{profile.id()}",
507507
"profileName": profile.ProfileName,
508508
"profileType": profile.ProfileType,
509509
"profileShape": "iSymmetrical",
@@ -520,7 +520,7 @@ def get_profile_properties(self, profile):
520520
def get_connection_data(self, itemList):
521521
return [
522522
{
523-
"ifcName": f"{rel.is_a()}|{rel.id()}",
523+
"referenceName": f"{rel.is_a()}|{rel.id()}",
524524
"id": rel.GlobalId,
525525
"relatingElement": f"{rel.RelatingStructuralMember.is_a()}|{rel.RelatingStructuralMember.id()}",
526526
"relatedConnection": f"{rel.RelatedStructuralConnection.is_a()}|{rel.RelatedStructuralConnection.id()}",

src/ifc2ca/scriptCodeAster.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ def __init__(self, dataFilename, asterFilename):
3232
self.create()
3333

3434
def getGroupName(self, name):
35-
info = name.split("|")
36-
sortName = "".join(c for c in info[0] if c.isupper())
37-
return f"{sortName[2:]}_{info[1]}"
35+
if "|" in name:
36+
info = name.split("|")
37+
sortName = "".join(c for c in info[0] if c.isupper())
38+
return f"{sortName[2:]}_{info[1]}"
39+
else:
40+
return name
3841

3942
def create(self):
4043

@@ -54,7 +57,7 @@ def create(self):
5457
for el in elements:
5558
for rel in el["connections"]:
5659
conn = [
57-
c for c in connections if c["ifcName"] == rel["relatedConnection"]
60+
c for c in connections if c["referenceName"] == rel["relatedConnection"]
5861
][0]
5962
rel["conn_string"] = None
6063
if conn["geometryType"] == "point":
@@ -98,21 +101,21 @@ def create(self):
98101

99102
edgeGroupNames = tuple(
100103
[
101-
self.getGroupName(el["ifcName"])
104+
self.getGroupName(el["referenceName"])
102105
for el in elements
103106
if el["geometryType"] == "line"
104107
]
105108
)
106109
faceGroupNames = tuple(
107110
[
108-
self.getGroupName(el["ifcName"])
111+
self.getGroupName(el["referenceName"])
109112
for el in elements
110113
if el["geometryType"] == "surface"
111114
]
112115
)
113116
point0DGroupNames = tuple(
114117
[
115-
self.getGroupName(el["ifcName"]) + "_0D"
118+
self.getGroupName(el["referenceName"]) + "_0D"
116119
for el in connections
117120
if el["geometryType"] == "point"
118121
]
@@ -132,7 +135,7 @@ def create(self):
132135
)
133136
point1DGroupNames = tuple(
134137
[
135-
self.getGroupName(el["ifcName"]) + "_0D"
138+
self.getGroupName(el["referenceName"]) + "_0D"
136139
for el in connections
137140
if el["geometryType"] == "line"
138141
]
@@ -153,14 +156,14 @@ def create(self):
153156
# 'dz': True
154157
# }
155158
if len(conn["unifiedGroupNames"]) >= 1:
156-
conn["unifiedGroupNames"].insert(0, self.getGroupName(conn["ifcName"]))
159+
conn["unifiedGroupNames"].insert(0, self.getGroupName(conn["referenceName"]))
157160
conn["unifiedGroupNames"] = tuple(conn["unifiedGroupNames"])
158161
unifiedConnection = True
159162
rigidLinkGroupNames.extend(
160163
[
161164
self.getGroupName(rel["relatingElement"])
162165
+ "_1DR_"
163-
+ self.getGroupName(conn["ifcName"])
166+
+ self.getGroupName(conn["referenceName"])
164167
for rel in conn["relatedElements"]
165168
if rel["eccentricity"]
166169
]
@@ -442,7 +445,7 @@ def create(self):
442445
),"""
443446

444447
context = {
445-
"groupName": self.getGroupName(el["ifcName"]),
448+
"groupName": self.getGroupName(el["referenceName"]),
446449
"thickness": el["thickness"],
447450
"localAxisX": tuple(el["orientation"][0]),
448451
}
@@ -469,7 +472,7 @@ def create(self):
469472
),"""
470473

471474
context = {
472-
"groupName": self.getGroupName(conn["ifcName"]) + "_0D",
475+
"groupName": self.getGroupName(conn["referenceName"]) + "_0D",
473476
"stiffnesses": conn["stiffnesses"],
474477
}
475478

@@ -504,7 +507,7 @@ def create(self):
504507
),"""
505508

506509
context = {
507-
"groupName": self.getGroupName(conn["ifcName"]) + "_0D",
510+
"groupName": self.getGroupName(conn["referenceName"]) + "_0D",
508511
"stiffnesses": conn["stiffnesses"],
509512
}
510513

@@ -530,7 +533,7 @@ def create(self):
530533
),"""
531534

532535
context = {
533-
"groupName": self.getGroupName(el["ifcName"]),
536+
"groupName": self.getGroupName(el["referenceName"]),
534537
"localAxisY": tuple(el["orientation"][1]),
535538
}
536539

@@ -546,7 +549,7 @@ def create(self):
546549
),"""
547550

548551
context = {
549-
"groupName": self.getGroupName(conn["ifcName"]) + "_0D",
552+
"groupName": self.getGroupName(conn["referenceName"]) + "_0D",
550553
"localAxesXY": tuple(conn["orientation"][0] + conn["orientation"][1]),
551554
}
552555

@@ -581,7 +584,7 @@ def create(self):
581584
),"""
582585

583586
context = {
584-
"groupName": self.getGroupName(conn["ifcName"]) + "_0D",
587+
"groupName": self.getGroupName(conn["referenceName"]) + "_0D",
585588
"localAxesXY": tuple(conn["orientation"][0] + conn["orientation"][1]),
586589
}
587590

@@ -999,7 +1002,7 @@ def calculateConstraints(self, rel):
9991002
rel["stiffnesses"] = tuple(stiffnesses)
10001003

10011004
def calculateRestraints(self, conn):
1002-
group = self.getGroupName(conn["ifcName"])
1005+
group = self.getGroupName(conn["referenceName"])
10031006
o = np.array(conn["orientation"]).transpose().tolist()
10041007
liaisons = {"groupNames": (group, group, group), "coeffs": [], "dofs": []}
10051008
stiffnesses = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

0 commit comments

Comments
 (0)