mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
changes in ifc2ca bonded case
This commit is contained in:
@@ -35,9 +35,12 @@ class COMMANDFILE:
|
|||||||
self.create()
|
self.create()
|
||||||
|
|
||||||
def getGroupName(self, name):
|
def getGroupName(self, name):
|
||||||
info = name.split("|")
|
if "|" in name:
|
||||||
sortName = "".join(c for c in info[0] if c.isupper())
|
info = name.split("|")
|
||||||
return f"{sortName[2:]}_{info[1]}"
|
sortName = "".join(c for c in info[0] if c.isupper())
|
||||||
|
return f"{sortName[2:]}_{info[1]}"
|
||||||
|
else:
|
||||||
|
return name
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
# Read data from input file
|
# Read data from input file
|
||||||
@@ -53,7 +56,7 @@ class COMMANDFILE:
|
|||||||
for el in elements:
|
for el in elements:
|
||||||
for rel in el["connections"]:
|
for rel in el["connections"]:
|
||||||
conn = [
|
conn = [
|
||||||
c for c in connections if c["ifcName"] == rel["relatedConnection"]
|
c for c in connections if c["referenceName"] == rel["relatedConnection"]
|
||||||
][0]
|
][0]
|
||||||
conn["relatedElements"].append(rel)
|
conn["relatedElements"].append(rel)
|
||||||
# End <--
|
# End <--
|
||||||
@@ -63,14 +66,14 @@ class COMMANDFILE:
|
|||||||
|
|
||||||
edgeGroupNames = tuple(
|
edgeGroupNames = tuple(
|
||||||
[
|
[
|
||||||
self.getGroupName(el["ifcName"])
|
self.getGroupName(el["referenceName"])
|
||||||
for el in elements
|
for el in elements
|
||||||
if el["geometryType"] == "line"
|
if el["geometryType"] == "line"
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
faceGroupNames = tuple(
|
faceGroupNames = tuple(
|
||||||
[
|
[
|
||||||
self.getGroupName(el["ifcName"])
|
self.getGroupName(el["referenceName"])
|
||||||
for el in elements
|
for el in elements
|
||||||
if el["geometryType"] == "surface"
|
if el["geometryType"] == "surface"
|
||||||
]
|
]
|
||||||
@@ -82,7 +85,7 @@ class COMMANDFILE:
|
|||||||
[
|
[
|
||||||
self.getGroupName(rel["relatingElement"])
|
self.getGroupName(rel["relatingElement"])
|
||||||
+ "_1DR_"
|
+ "_1DR_"
|
||||||
+ self.getGroupName(conn["ifcName"])
|
+ self.getGroupName(conn["referenceName"])
|
||||||
for rel in conn["relatedElements"]
|
for rel in conn["relatedElements"]
|
||||||
if rel["eccentricity"]
|
if rel["eccentricity"]
|
||||||
]
|
]
|
||||||
@@ -336,7 +339,7 @@ element = AFFE_CARA_ELEM(
|
|||||||
),"""
|
),"""
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"groupName": self.getGroupName(el["ifcName"]),
|
"groupName": self.getGroupName(el["referenceName"]),
|
||||||
"thickness": el["thickness"] / ScaleFactor,
|
"thickness": el["thickness"] / ScaleFactor,
|
||||||
"localAxisX": tuple(el["orientation"][0]),
|
"localAxisX": tuple(el["orientation"][0]),
|
||||||
}
|
}
|
||||||
@@ -363,7 +366,7 @@ element = AFFE_CARA_ELEM(
|
|||||||
),"""
|
),"""
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"groupName": self.getGroupName(el["ifcName"]),
|
"groupName": self.getGroupName(el["referenceName"]),
|
||||||
"localAxisY": tuple(el["orientation"][1]),
|
"localAxisY": tuple(el["orientation"][1]),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,7 +568,7 @@ FIN()
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
fileNames = ["building_02"]
|
fileNames = ["test"]
|
||||||
files = fileNames
|
files = fileNames
|
||||||
|
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ from pathlib import Path
|
|||||||
|
|
||||||
flatten = itertools.chain.from_iterable
|
flatten = itertools.chain.from_iterable
|
||||||
|
|
||||||
ScaleFactor = 1.0
|
|
||||||
decimals = 2
|
|
||||||
|
|
||||||
|
|
||||||
class MODEL:
|
class MODEL:
|
||||||
def __init__(self, dataFilename, medFilename, meshSize, zGround):
|
def __init__(self, dataFilename, medFilename, meshSize, zGround):
|
||||||
self.dataFilename = dataFilename
|
self.dataFilename = dataFilename
|
||||||
@@ -46,9 +42,12 @@ class MODEL:
|
|||||||
self.create()
|
self.create()
|
||||||
|
|
||||||
def getGroupName(self, name):
|
def getGroupName(self, name):
|
||||||
info = name.split("|")
|
if "|" in name:
|
||||||
sortName = "".join(c for c in info[0] if c.isupper())
|
info = name.split("|")
|
||||||
return f"{sortName[2:]}_{info[1]}"
|
sortName = "".join(c for c in info[0] if c.isupper())
|
||||||
|
return f"{sortName[2:]}_{info[1]}"
|
||||||
|
else:
|
||||||
|
return name
|
||||||
|
|
||||||
def makePoint(self, pl):
|
def makePoint(self, pl):
|
||||||
"""Function to define a Point from
|
"""Function to define a Point from
|
||||||
@@ -84,8 +83,6 @@ class MODEL:
|
|||||||
return self.geompy.MakeFaceWires(LineList, 1)
|
return self.geompy.MakeFaceWires(LineList, 1)
|
||||||
|
|
||||||
def makeObject(self, geometry, geometryType):
|
def makeObject(self, geometry, geometryType):
|
||||||
geometry = np.round(np.array(geometry), decimals=decimals) / ScaleFactor
|
|
||||||
geometry = geometry.tolist()
|
|
||||||
if geometryType == "point":
|
if geometryType == "point":
|
||||||
return self.makePoint(geometry)
|
return self.makePoint(geometry)
|
||||||
if geometryType == "line":
|
if geometryType == "line":
|
||||||
@@ -144,8 +141,8 @@ class MODEL:
|
|||||||
conn["relatedElements"] = []
|
conn["relatedElements"] = []
|
||||||
# End <--
|
# End <--
|
||||||
|
|
||||||
meshSize = self.meshSize / ScaleFactor
|
meshSize = self.meshSize
|
||||||
zGround = self.zGround / ScaleFactor
|
zGround = self.zGround
|
||||||
|
|
||||||
dec = 5 # 4 decimals for length in mm
|
dec = 5 # 4 decimals for length in mm
|
||||||
tol = 10 ** (-dec - 3 + 1)
|
tol = 10 ** (-dec - 3 + 1)
|
||||||
@@ -199,7 +196,7 @@ class MODEL:
|
|||||||
el["linkObjs"] = [None for _ in el["connections"]]
|
el["linkObjs"] = [None for _ in el["connections"]]
|
||||||
for j, rel in enumerate(el["connections"]):
|
for j, rel in enumerate(el["connections"]):
|
||||||
conn = [
|
conn = [
|
||||||
c for c in connections if c["ifcName"] == rel["relatedConnection"]
|
c for c in connections if c["referenceName"] == rel["relatedConnection"]
|
||||||
][0]
|
][0]
|
||||||
if rel["eccentricity"]:
|
if rel["eccentricity"]:
|
||||||
rel["index"] = len(conn["relatedElements"]) + 1
|
rel["index"] = len(conn["relatedElements"]) + 1
|
||||||
@@ -260,7 +257,7 @@ class MODEL:
|
|||||||
# el['partObj'] = geompy.RestoreGivenSubShapes(bldComp, [el['partObj']], GEOM.FSM_GetInPlace, False, False)[0]
|
# el['partObj'] = geompy.RestoreGivenSubShapes(bldComp, [el['partObj']], GEOM.FSM_GetInPlace, False, False)[0]
|
||||||
el["elemObj"] = geompy.GetInPlace(bldComp, el["elemObj"], True)
|
el["elemObj"] = geompy.GetInPlace(bldComp, el["elemObj"], True)
|
||||||
geompy.addToStudyInFather(
|
geompy.addToStudyInFather(
|
||||||
bldComp, el["elemObj"], self.getGroupName(el["ifcName"])
|
bldComp, el["elemObj"], self.getGroupName(el["referenceName"])
|
||||||
)
|
)
|
||||||
|
|
||||||
for j, rel in enumerate(el["connections"]):
|
for j, rel in enumerate(el["connections"]):
|
||||||
@@ -271,7 +268,7 @@ class MODEL:
|
|||||||
geompy.addToStudyInFather(
|
geompy.addToStudyInFather(
|
||||||
bldComp,
|
bldComp,
|
||||||
el["linkObjs"][j],
|
el["linkObjs"][j],
|
||||||
self.getGroupName(el["ifcName"])
|
self.getGroupName(el["referenceName"])
|
||||||
+ "_1DR_"
|
+ "_1DR_"
|
||||||
+ self.getGroupName(rel["relatedConnection"]),
|
+ self.getGroupName(rel["relatedConnection"]),
|
||||||
)
|
)
|
||||||
@@ -353,22 +350,22 @@ class MODEL:
|
|||||||
if el["geometryType"] == "surface":
|
if el["geometryType"] == "surface":
|
||||||
shapeType = SMESH.FACE
|
shapeType = SMESH.FACE
|
||||||
tempgroup = bldMesh.GroupOnGeom(
|
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"]):
|
for j, rel in enumerate(el["connections"]):
|
||||||
if rel["eccentricity"]:
|
if rel["eccentricity"]:
|
||||||
tempgroup = bldMesh.GroupOnGeom(
|
tempgroup = bldMesh.GroupOnGeom(
|
||||||
el["linkObjs"][j],
|
el["linkObjs"][j],
|
||||||
self.getGroupName(el["ifcName"])
|
self.getGroupName(el["referenceName"])
|
||||||
+ "_1DR_"
|
+ "_1DR_"
|
||||||
+ self.getGroupName(rel["relatedConnection"]),
|
+ self.getGroupName(rel["relatedConnection"]),
|
||||||
SMESH.EDGE,
|
SMESH.EDGE,
|
||||||
)
|
)
|
||||||
smesh.SetName(
|
smesh.SetName(
|
||||||
tempgroup,
|
tempgroup,
|
||||||
self.getGroupName(el["ifcName"])
|
self.getGroupName(el["referenceName"])
|
||||||
+ "_1DR_"
|
+ "_1DR_"
|
||||||
+ self.getGroupName(rel["relatedConnection"]),
|
+ self.getGroupName(rel["relatedConnection"]),
|
||||||
)
|
)
|
||||||
@@ -416,10 +413,10 @@ class MODEL:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
fileNames = ["building_02"]
|
fileNames = ["test"]
|
||||||
files = fileNames
|
files = fileNames
|
||||||
|
|
||||||
meshSize = 500
|
meshSize = 0.5
|
||||||
zGround = 0
|
zGround = 0
|
||||||
|
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
|
|||||||
Reference in New Issue
Block a user