changes in ifc2ca standard case

This commit is contained in:
Jesusbill
2021-12-17 17:01:18 +01:00
parent dd6912bdaa
commit 37d20eb360
4 changed files with 75 additions and 69 deletions
+4 -4
View File
@@ -94,8 +94,8 @@ class CA2IFC:
)
ifcMaterialProfileSets = [None for _ in range(len(mpSets))]
for i, mpSet in enumerate(mpSets):
materialIndex = [mat["ifcName"] for mat in self.data["db"]["materials"]].index(mpSet.split("-")[0])
profileIndex = [prof["ifcName"] for prof in self.data["db"]["profiles"]].index(mpSet.split("-")[1])
materialIndex = [mat["referenceName"] for mat in self.data["db"]["materials"]].index(mpSet.split("-")[0])
profileIndex = [prof["referenceName"] for prof in self.data["db"]["profiles"]].index(mpSet.split("-")[1])
material = ifcMaterials[materialIndex]
profile = ifcProfiles[profileIndex]
matProf = self.f.createIfcMaterialProfile(
@@ -218,7 +218,7 @@ class CA2IFC:
for i, mat in enumerate(self.data["db"]["materials"]):
groupOfElements = []
for j, el in enumerate(self.data["elements"]):
if el["geometryType"] == "surface" and el["material"] == mat["ifcName"]:
if el["geometryType"] == "surface" and el["material"] == mat["referenceName"]:
groupOfElements.append(ifcElements[j])
if groupOfElements:
self.f.createIfcRelAssociatesMaterial(
@@ -228,7 +228,7 @@ class CA2IFC:
# create connections with elements
for i, el in enumerate(self.data["elements"]):
for conn in el["connections"]:
j = [c["ifcName"] for c in self.data["connections"]].index(conn["relatedConnection"])
j = [c["referenceName"] for c in self.data["connections"]].index(conn["relatedConnection"])
geometryType = self.data["connections"][j]["geometryType"]
if conn["appliedCondition"]:
+11 -11
View File
@@ -46,7 +46,7 @@ class IFC2CA:
id = int(mat.split("|")[1])
material = self.get_material_properties(self.file.by_id(id))
material["relatedElements"] = [
e["ifcName"]
e["referenceName"]
for e in elements
if "material" in e and e["material"] == mat
]
@@ -60,14 +60,14 @@ class IFC2CA:
id = int(prof.split("|")[1])
profile = self.get_profile_properties(self.file.by_id(id))
profile["relatedElements"] = [
e["ifcName"]
e["referenceName"]
for e in elements
if "profile" in e and e["profile"] == prof
]
profiledb.append(profile)
self.result = {
"ifcName": model.is_a() + "|" + str(model.id()),
"referenceName": model.is_a() + "|" + str(model.id()),
"name": model.Name,
"id": model.GlobalId,
"elements": elements,
@@ -157,7 +157,7 @@ class IFC2CA:
)
return {
"ifcName": f"{item.is_a()}|{item.id()}",
"referenceName": f"{item.is_a()}|{item.id()}",
"name": item.Name,
"id": item.GlobalId,
"geometryType": "line",
@@ -200,7 +200,7 @@ class IFC2CA:
)
return {
"ifcName": f"{item.is_a()}|{item.id()}",
"referenceName": f"{item.is_a()}|{item.id()}",
"name": item.Name,
"id": item.GlobalId,
"geometryType": "surface",
@@ -231,7 +231,7 @@ class IFC2CA:
)
return {
"ifcName": f"{item.is_a()}|{item.id()}",
"referenceName": f"{item.is_a()}|{item.id()}",
"name": item.Name,
"id": item.GlobalId,
"geometryType": "point",
@@ -262,7 +262,7 @@ class IFC2CA:
)
return {
"ifcName": f"{item.is_a()}|{item.id()}",
"referenceName": f"{item.is_a()}|{item.id()}",
"name": item.Name,
"id": item.GlobalId,
"geometryType": "line",
@@ -460,7 +460,7 @@ class IFC2CA:
commonProps = self.get_pset_properties(psets, None)
return {
"ifcName": material.is_a() + "|" + str(material.id()),
"referenceName": material.is_a() + "|" + str(material.id()),
"name": material.Name,
"category": material.Category,
"mechProps": mechProps,
@@ -486,7 +486,7 @@ class IFC2CA:
def get_profile_properties(self, profile):
if profile.is_a("IfcRectangleProfileDef"):
return {
"ifcName": profile.is_a() + "|" + str(profile.id()),
"referenceName": profile.is_a() + "|" + str(profile.id()),
"profileName": profile.ProfileName,
"profileType": profile.ProfileType,
"profileShape": "rectangular",
@@ -503,7 +503,7 @@ class IFC2CA:
mechProps = self.get_i_section_properties(profile, "iSymmetrical")
return {
"ifcName": f"{profile.is_a()}|{profile.id()}",
"referenceName": f"{profile.is_a()}|{profile.id()}",
"profileName": profile.ProfileName,
"profileType": profile.ProfileType,
"profileShape": "iSymmetrical",
@@ -520,7 +520,7 @@ class IFC2CA:
def get_connection_data(self, itemList):
return [
{
"ifcName": f"{rel.is_a()}|{rel.id()}",
"referenceName": f"{rel.is_a()}|{rel.id()}",
"id": rel.GlobalId,
"relatingElement": f"{rel.RelatingStructuralMember.is_a()}|{rel.RelatingStructuralMember.id()}",
"relatedConnection": f"{rel.RelatedStructuralConnection.is_a()}|{rel.RelatedStructuralConnection.id()}",
+20 -17
View File
@@ -32,9 +32,12 @@ class COMMANDFILE:
self.create()
def getGroupName(self, name):
info = name.split("|")
sortName = "".join(c for c in info[0] if c.isupper())
return f"{sortName[2:]}_{info[1]}"
if "|" in name:
info = name.split("|")
sortName = "".join(c for c in info[0] if c.isupper())
return f"{sortName[2:]}_{info[1]}"
else:
return name
def create(self):
@@ -54,7 +57,7 @@ class COMMANDFILE:
for el in elements:
for rel in el["connections"]:
conn = [
c for c in connections if c["ifcName"] == rel["relatedConnection"]
c for c in connections if c["referenceName"] == rel["relatedConnection"]
][0]
rel["conn_string"] = None
if conn["geometryType"] == "point":
@@ -98,21 +101,21 @@ class COMMANDFILE:
edgeGroupNames = tuple(
[
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
for el in elements
if el["geometryType"] == "line"
]
)
faceGroupNames = tuple(
[
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
for el in elements
if el["geometryType"] == "surface"
]
)
point0DGroupNames = tuple(
[
self.getGroupName(el["ifcName"]) + "_0D"
self.getGroupName(el["referenceName"]) + "_0D"
for el in connections
if el["geometryType"] == "point"
]
@@ -132,7 +135,7 @@ class COMMANDFILE:
)
point1DGroupNames = tuple(
[
self.getGroupName(el["ifcName"]) + "_0D"
self.getGroupName(el["referenceName"]) + "_0D"
for el in connections
if el["geometryType"] == "line"
]
@@ -153,14 +156,14 @@ class COMMANDFILE:
# 'dz': True
# }
if len(conn["unifiedGroupNames"]) >= 1:
conn["unifiedGroupNames"].insert(0, self.getGroupName(conn["ifcName"]))
conn["unifiedGroupNames"].insert(0, self.getGroupName(conn["referenceName"]))
conn["unifiedGroupNames"] = tuple(conn["unifiedGroupNames"])
unifiedConnection = True
rigidLinkGroupNames.extend(
[
self.getGroupName(rel["relatingElement"])
+ "_1DR_"
+ self.getGroupName(conn["ifcName"])
+ self.getGroupName(conn["referenceName"])
for rel in conn["relatedElements"]
if rel["eccentricity"]
]
@@ -442,7 +445,7 @@ element = AFFE_CARA_ELEM(
),"""
context = {
"groupName": self.getGroupName(el["ifcName"]),
"groupName": self.getGroupName(el["referenceName"]),
"thickness": el["thickness"],
"localAxisX": tuple(el["orientation"][0]),
}
@@ -469,7 +472,7 @@ element = AFFE_CARA_ELEM(
),"""
context = {
"groupName": self.getGroupName(conn["ifcName"]) + "_0D",
"groupName": self.getGroupName(conn["referenceName"]) + "_0D",
"stiffnesses": conn["stiffnesses"],
}
@@ -504,7 +507,7 @@ element = AFFE_CARA_ELEM(
),"""
context = {
"groupName": self.getGroupName(conn["ifcName"]) + "_0D",
"groupName": self.getGroupName(conn["referenceName"]) + "_0D",
"stiffnesses": conn["stiffnesses"],
}
@@ -530,7 +533,7 @@ element = AFFE_CARA_ELEM(
),"""
context = {
"groupName": self.getGroupName(el["ifcName"]),
"groupName": self.getGroupName(el["referenceName"]),
"localAxisY": tuple(el["orientation"][1]),
}
@@ -546,7 +549,7 @@ element = AFFE_CARA_ELEM(
),"""
context = {
"groupName": self.getGroupName(conn["ifcName"]) + "_0D",
"groupName": self.getGroupName(conn["referenceName"]) + "_0D",
"localAxesXY": tuple(conn["orientation"][0] + conn["orientation"][1]),
}
@@ -581,7 +584,7 @@ element = AFFE_CARA_ELEM(
),"""
context = {
"groupName": self.getGroupName(conn["ifcName"]) + "_0D",
"groupName": self.getGroupName(conn["referenceName"]) + "_0D",
"localAxesXY": tuple(conn["orientation"][0] + conn["orientation"][1]),
}
@@ -999,7 +1002,7 @@ FIN()
rel["stiffnesses"] = tuple(stiffnesses)
def calculateRestraints(self, conn):
group = self.getGroupName(conn["ifcName"])
group = self.getGroupName(conn["referenceName"])
o = np.array(conn["orientation"]).transpose().tolist()
liaisons = {"groupNames": (group, group, group), "coeffs": [], "dofs": []}
stiffnesses = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+40 -37
View File
@@ -42,9 +42,12 @@ class MODEL:
self.create()
def getGroupName(self, name):
info = name.split("|")
sortName = "".join(c for c in info[0] if c.isupper())
return f"{sortName[2:]}_{info[1]}"
if "|" in name:
info = name.split("|")
sortName = "".join(c for c in info[0] if c.isupper())
return f"{sortName[2:]}_{info[1]}"
else:
return name
def makePoint(self, pl):
"""Function to define a Point from
@@ -179,7 +182,7 @@ class MODEL:
el["linkPointObjs"] = [[None, None] for _ in el["connections"]]
for j, rel in enumerate(el["connections"]):
conn = [
c for c in connections if c["ifcName"] == rel["relatedConnection"]
c for c in connections if c["referenceName"] == rel["relatedConnection"]
][0]
if rel["eccentricity"]:
rel["index"] = len(conn["relatedElements"]) + 1
@@ -237,13 +240,13 @@ class MODEL:
# Loop 2
for el in elements:
# geompy.addToStudy(el['partObj'], self.getGroupName(el['ifcName']))
# geompy.addToStudy(el['partObj'], self.getGroupName(el['referenceName']))
geompy.addToStudyInFather(
el["partObj"], el["elemObj"], self.getGroupName(el["ifcName"])
el["partObj"], el["elemObj"], self.getGroupName(el["referenceName"])
)
for j, rel in enumerate(el["connections"]):
conn = [
c for c in connections if c["ifcName"] == rel["relatedConnection"]
c for c in connections if c["referenceName"] == rel["relatedConnection"]
][0]
rel["conn_string"] = None
if conn["geometryType"] == "point":
@@ -255,20 +258,20 @@ class MODEL:
geompy.addToStudyInFather(
el["partObj"],
el["connObjs"][j],
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
+ rel["conn_string"]
+ self.getGroupName(rel["relatedConnection"]),
)
if rel["eccentricity"]:
pass
# geompy.addToStudy(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
# geompy.addToStudyInFather(el['linkObjs'][j], el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(el['ifcName']))
# geompy.addToStudy(el['linkObjs'][j], self.getGroupName(el['referenceName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
# geompy.addToStudyInFather(el['linkObjs'][j], el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(el['referenceName']))
# geompy.addToStudyInFather(el['linkObjs'][j], el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index'])
for conn in connections:
# geompy.addToStudy(conn['connObj'], self.getGroupName(conn['ifcName']))
# geompy.addToStudy(conn['connObj'], self.getGroupName(conn['referenceName']))
geompy.addToStudyInFather(
conn["connObj"], conn["connObj"], self.getGroupName(conn["ifcName"])
conn["connObj"], conn["connObj"], self.getGroupName(conn["referenceName"])
)
elapsed_time = time.time() - init_time
@@ -298,14 +301,14 @@ class MODEL:
for el in elements:
# el['partObj'] = geompy.RestoreGivenSubShapes(bldComp, [el['partObj']], GEOM.FSM_GetInPlace, False, False)[0]
geompy.addToStudyInFather(
bldComp, el["elemObj"], self.getGroupName(el["ifcName"])
bldComp, el["elemObj"], self.getGroupName(el["referenceName"])
)
for j, rel in enumerate(el["connections"]):
geompy.addToStudyInFather(
bldComp,
el["connObjs"][j],
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
+ rel["conn_string"]
+ self.getGroupName(rel["relatedConnection"]),
)
@@ -313,7 +316,7 @@ class MODEL:
geompy.addToStudyInFather(
bldComp,
el["linkObjs"][j],
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
+ "_1DR_"
+ self.getGroupName(rel["relatedConnection"]),
)
@@ -322,7 +325,7 @@ class MODEL:
el["linkPointObjs"][j][0],
self.getGroupName(rel["relatedConnection"])
+ "_0DC_"
+ self.getGroupName(el["ifcName"]),
+ self.getGroupName(el["referenceName"]),
)
geompy.addToStudyInFather(
bldComp,
@@ -334,7 +337,7 @@ class MODEL:
for conn in connections:
# conn['connObj'] = geompy.RestoreGivenSubShapes(bldComp, [conn['connObj']], GEOM.FSM_GetInPlace, False, False)[0]
geompy.addToStudyInFather(
bldComp, conn["connObj"], self.getGroupName(conn["ifcName"])
bldComp, conn["connObj"], self.getGroupName(conn["referenceName"])
)
elapsed_time = time.time() - init_time
@@ -402,21 +405,21 @@ class MODEL:
if el["geometryType"] == "surface":
shapeType = SMESH.FACE
tempgroup = bldMesh.GroupOnGeom(
el["elemObj"], self.getGroupName(el["ifcName"]), shapeType
el["elemObj"], self.getGroupName(el["referenceName"]), shapeType
)
smesh.SetName(tempgroup, self.getGroupName(el["ifcName"]))
smesh.SetName(tempgroup, self.getGroupName(el["referenceName"]))
for j, rel in enumerate(el["connections"]):
tempgroup = bldMesh.GroupOnGeom(
el["connObjs"][j],
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
+ rel["conn_string"]
+ self.getGroupName(rel["relatedConnection"]),
SMESH.NODE,
)
smesh.SetName(
tempgroup,
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
+ rel["conn_string"]
+ self.getGroupName(rel["relatedConnection"]),
)
@@ -426,14 +429,14 @@ class MODEL:
if rel["eccentricity"]:
tempgroup = bldMesh.GroupOnGeom(
el["linkObjs"][j],
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
+ "_1DR_"
+ self.getGroupName(rel["relatedConnection"]),
SMESH.EDGE,
)
smesh.SetName(
tempgroup,
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
+ "_1DR_"
+ self.getGroupName(rel["relatedConnection"]),
)
@@ -442,14 +445,14 @@ class MODEL:
el["linkPointObjs"][j][0],
self.getGroupName(rel["relatedConnection"])
+ "_0DC_"
+ self.getGroupName(el["ifcName"]),
+ self.getGroupName(el["referenceName"]),
SMESH.NODE,
)
smesh.SetName(
tempgroup,
self.getGroupName(rel["relatedConnection"])
+ "_0DC_"
+ self.getGroupName(el["ifcName"]),
+ self.getGroupName(el["referenceName"]),
)
rel["eccNode"] = (
bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)
@@ -470,43 +473,43 @@ class MODEL:
for conn in connections:
tempgroup = bldMesh.GroupOnGeom(
conn["connObj"], self.getGroupName(conn["ifcName"]), SMESH.NODE
conn["connObj"], self.getGroupName(conn["referenceName"]), SMESH.NODE
)
smesh.SetName(tempgroup, self.getGroupName(conn["ifcName"]))
smesh.SetName(tempgroup, self.getGroupName(conn["referenceName"]))
nodesId = bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)
tempgroup = bldMesh.Add0DElementsToAllNodes(
nodesId, self.getGroupName(conn["ifcName"])
nodesId, self.getGroupName(conn["referenceName"])
)
smesh.SetName(tempgroup, self.getGroupName(conn["ifcName"] + "_0D"))
smesh.SetName(tempgroup, self.getGroupName(conn["referenceName"] + "_0D"))
if conn["geometryType"] == "point":
conn["node"] = nodesId.GetIDs()[0]
if conn["geometryType"] == "line":
tempgroup = bldMesh.GroupOnGeom(
conn["connObj"], self.getGroupName(conn["ifcName"]), SMESH.EDGE
conn["connObj"], self.getGroupName(conn["referenceName"]), SMESH.EDGE
)
smesh.SetName(tempgroup, self.getGroupName(conn["ifcName"]))
smesh.SetName(tempgroup, self.getGroupName(conn["referenceName"]))
if conn["geometryType"] == "surface":
tempgroup = bldMesh.GroupOnGeom(
conn["connObj"], self.getGroupName(conn["ifcName"]), SMESH.FACE
conn["connObj"], self.getGroupName(conn["referenceName"]), SMESH.FACE
)
smesh.SetName(tempgroup, self.getGroupName(conn["ifcName"]))
smesh.SetName(tempgroup, self.getGroupName(conn["referenceName"]))
# create 1D SEG2 spring elements
for el in elements:
for j, rel in enumerate(el["connections"]):
conn = [
c for c in connections if c["ifcName"] == rel["relatedConnection"]
c for c in connections if c["referenceName"] == rel["relatedConnection"]
][0]
if conn["geometryType"] == "point":
grpName = bldMesh.CreateEmptyGroup(
SMESH.EDGE,
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
+ "_1DS_"
+ self.getGroupName(rel["relatedConnection"]),
)
smesh.SetName(
grpName,
self.getGroupName(el["ifcName"])
self.getGroupName(el["referenceName"])
+ "_1DS_"
+ self.getGroupName(rel["relatedConnection"]),
)
@@ -514,7 +517,7 @@ class MODEL:
conn = [
conn
for conn in connections
if conn["ifcName"] == rel["relatedConnection"]
if conn["referenceName"] == rel["relatedConnection"]
][0]
grpName.Add([bldMesh.AddEdge([conn["node"], rel["node"]])])
else: