minor changes in ifc2ca scripts

This commit is contained in:
Jesusbill
2021-12-12 19:03:14 +01:00
parent 664c49a07d
commit 4e9a5f246f
5 changed files with 76 additions and 85 deletions
+16 -14
View File
@@ -1,4 +1,3 @@
# Ifc2CA - IFC Code_Aster utility
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
#
@@ -27,6 +26,7 @@ import salome_notebook
import salome_version
import numpy as np
import itertools
from pathlib import Path
flatten = itertools.chain.from_iterable
@@ -48,7 +48,7 @@ class MODEL:
def getGroupName(self, name):
info = name.split("|")
sortName = "".join(c for c in info[0] if c.isupper())
return str(sortName + "_" + info[1])
return f"{sortName[2:]}_{info[1]}"
def makePoint(self, pl):
"""Function to define a Point from
@@ -234,7 +234,7 @@ class MODEL:
[e["elemObj"] for e in elements if e["geometryType"] == "line"]
)
# Define group object and add to study
curveCompound = geompy.GetInPlace(bldComp, compoundTemp)
curveCompound = geompy.GetInPlace(bldComp, compoundTemp, True)
geompy.addToStudyInFather(bldComp, curveCompound, "CurveMembers")
if len([e for e in elements if e["geometryType"] == "surface"]) > 0:
@@ -243,7 +243,7 @@ class MODEL:
[e["elemObj"] for e in elements if e["geometryType"] == "surface"]
)
# Define group object and add to study
surfaceCompound = geompy.GetInPlace(bldComp, compoundTemp)
surfaceCompound = geompy.GetInPlace(bldComp, compoundTemp, True)
geompy.addToStudyInFather(bldComp, surfaceCompound, "SurfaceMembers")
linkObjs = list(
@@ -253,19 +253,21 @@ class MODEL:
# Make compound of requested group
compoundTemp = geompy.MakeCompound(linkObjs)
# Define group object and add to study
rigidCompound = geompy.GetInPlace(bldComp, compoundTemp)
rigidCompound = geompy.GetInPlace(bldComp, compoundTemp, True)
geompy.addToStudyInFather(bldComp, rigidCompound, "RigidMembers")
for el in elements:
# el['partObj'] = geompy.RestoreGivenSubShapes(bldComp, [el['partObj']], GEOM.FSM_GetInPlace, False, False)[0]
el["elemObj"] = geompy.GetInPlace(bldComp, el["elemObj"])
el["elemObj"] = geompy.GetInPlace(bldComp, el["elemObj"], True)
geompy.addToStudyInFather(
bldComp, el["elemObj"], self.getGroupName(el["ifcName"])
)
for j, rel in enumerate(el["connections"]):
if rel["eccentricity"]: # point geometry
el["linkObjs"][j] = geompy.GetInPlace(bldComp, el["linkObjs"][j])
el["linkObjs"][j] = geompy.GetInPlace(
bldComp, el["linkObjs"][j], True
)
geompy.addToStudyInFather(
bldComp,
el["linkObjs"][j],
@@ -337,9 +339,7 @@ class MODEL:
smesh.SetName(tempgroup, "CurveMembers")
if len([e for e in elements if e["geometryType"] == "surface"]) > 0:
tempgroup = bldMesh.GroupOnGeom(
surfaceCompound, "SurfaceMembers", SMESH.FACE
)
tempgroup = bldMesh.GroupOnGeom(surfaceCompound, "SurfaceMembers", SMESH.FACE)
smesh.SetName(tempgroup, "SurfaceMembers")
if len(linkObjs) > 0:
@@ -423,7 +423,9 @@ if __name__ == "__main__":
zGround = 0
for fileName in files:
BASE_PATH = "/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/models/"
DATAFILENAME = BASE_PATH + fileName + "/" + fileName + ".json"
MEDFILENAME = BASE_PATH + fileName + "/" + fileName + ".med"
model = MODEL(DATAFILENAME, MEDFILENAME, meshSize, zGround)
BASE_PATH = Path(
"/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/models/"
)
DATAFILENAME = BASE_PATH / fileName / f"{fileName}.json"
MEDFILENAME = BASE_PATH / fileName / f"{fileName}.med"
model = MODEL(DATAFILENAME, str(MEDFILENAME), meshSize, zGround)