mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
minor changes in ifc2ca scripts
This commit is contained in:
+30
-45
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# Ifc2CA - IFC Code_Aster utility
|
# Ifc2CA - IFC Code_Aster utility
|
||||||
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
|
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
|
||||||
#
|
#
|
||||||
@@ -22,6 +21,7 @@ from __future__ import print_function
|
|||||||
import json
|
import json
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
class IFC2CA:
|
class IFC2CA:
|
||||||
@@ -104,19 +104,12 @@ class IFC2CA:
|
|||||||
material_profile = self.get_material_profile(item)
|
material_profile = self.get_material_profile(item)
|
||||||
if not representation:
|
if not representation:
|
||||||
self.warnings.append(
|
self.warnings.append(
|
||||||
"No representation defined for %s. Member excluded"
|
f"No representation defined for {item.is_a()}|{item.id()}. Member excluded"
|
||||||
% (item.is_a() + "|" + str(item.id()))
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if not material_profile:
|
if not material_profile:
|
||||||
self.warnings.append(
|
self.warnings.append(f"No material defined for {item.is_a()}|{item.id()}")
|
||||||
"No material defined for in %s"
|
self.warnings.append(f"No profile defined for {item.is_a()}|{item.id()}")
|
||||||
% (item.is_a() + "|" + str(item.id()))
|
|
||||||
)
|
|
||||||
self.warnings.append(
|
|
||||||
"No profile defined for in %s"
|
|
||||||
% (item.is_a() + "|" + str(item.id()))
|
|
||||||
)
|
|
||||||
materialId = None
|
materialId = None
|
||||||
profileId = None
|
profileId = None
|
||||||
else:
|
else:
|
||||||
@@ -143,7 +136,7 @@ class IFC2CA:
|
|||||||
f"{np.linalg.norm(np.array(c['eccentricity']['pointOnElement']))} > {length}"
|
f"{np.linalg.norm(np.array(c['eccentricity']['pointOnElement']))} > {length}"
|
||||||
)
|
)
|
||||||
self.warnings.append(
|
self.warnings.append(
|
||||||
f"Eccentricity in {item.is_a()}|{str(item.id())} corrected"
|
f"Eccentricity in {item.is_a()}|{item.id()} corrected"
|
||||||
)
|
)
|
||||||
c["eccentricity"]["pointOnElement"][0] = length
|
c["eccentricity"]["pointOnElement"][0] = length
|
||||||
# End <--
|
# End <--
|
||||||
@@ -164,7 +157,7 @@ class IFC2CA:
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"ifcName": item.is_a() + "|" + str(item.id()),
|
"ifcName": f"{item.is_a()}|{item.id()}",
|
||||||
"name": item.Name,
|
"name": item.Name,
|
||||||
"id": item.GlobalId,
|
"id": item.GlobalId,
|
||||||
"geometryType": "line",
|
"geometryType": "line",
|
||||||
@@ -181,15 +174,11 @@ class IFC2CA:
|
|||||||
material = self.get_material_profile(item)
|
material = self.get_material_profile(item)
|
||||||
if not representation:
|
if not representation:
|
||||||
self.warnings.append(
|
self.warnings.append(
|
||||||
"No representation defined for %s. Member excluded"
|
f"No representation defined for {item.is_a()}|{item.id()}. Member excluded"
|
||||||
% (item.is_a() + "|" + str(item.id()))
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if not material:
|
if not material:
|
||||||
self.warnings.append(
|
self.warnings.append(f"No material defined for {item.is_a()}|{item.id()}")
|
||||||
"No material defined for in %s"
|
|
||||||
% (item.is_a() + "|" + str(item.id()))
|
|
||||||
)
|
|
||||||
materialId = None
|
materialId = None
|
||||||
else:
|
else:
|
||||||
materialId = material.is_a() + "|" + str(material.id())
|
materialId = material.is_a() + "|" + str(material.id())
|
||||||
@@ -211,7 +200,7 @@ class IFC2CA:
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"ifcName": item.is_a() + "|" + str(item.id()),
|
"ifcName": f"{item.is_a()}|{item.id()}",
|
||||||
"name": item.Name,
|
"name": item.Name,
|
||||||
"id": item.GlobalId,
|
"id": item.GlobalId,
|
||||||
"geometryType": "surface",
|
"geometryType": "surface",
|
||||||
@@ -227,8 +216,7 @@ class IFC2CA:
|
|||||||
representation = self.get_representation(item, "Vertex")
|
representation = self.get_representation(item, "Vertex")
|
||||||
if not representation:
|
if not representation:
|
||||||
self.warnings.append(
|
self.warnings.append(
|
||||||
"No representation defined for %s. Connection excluded"
|
f"No representation defined for {item.is_a()}|{item.id()}. Member excluded"
|
||||||
% (item.is_a() + "|" + str(item.id()))
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -243,7 +231,7 @@ class IFC2CA:
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"ifcName": item.is_a() + "|" + str(item.id()),
|
"ifcName": f"{item.is_a()}|{item.id()}",
|
||||||
"name": item.Name,
|
"name": item.Name,
|
||||||
"id": item.GlobalId,
|
"id": item.GlobalId,
|
||||||
"geometryType": "point",
|
"geometryType": "point",
|
||||||
@@ -251,8 +239,7 @@ class IFC2CA:
|
|||||||
"orientation": orientation,
|
"orientation": orientation,
|
||||||
"appliedCondition": self.get_connection_input(item, "point"),
|
"appliedCondition": self.get_connection_input(item, "point"),
|
||||||
"relatedElements": [
|
"relatedElements": [
|
||||||
con.is_a() + "|" + str(con.id())
|
f"{con.is_a()}|{con.id()}" for con in item.ConnectsStructuralMembers
|
||||||
for con in item.ConnectsStructuralMembers
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,8 +247,7 @@ class IFC2CA:
|
|||||||
representation = self.get_representation(item, "Edge")
|
representation = self.get_representation(item, "Edge")
|
||||||
if not representation:
|
if not representation:
|
||||||
self.warnings.append(
|
self.warnings.append(
|
||||||
"No representation defined for %s. Connection excluded"
|
f"No representation defined for {item.is_a()}|{item.id()}. Member excluded"
|
||||||
% (item.is_a() + "|" + str(item.id()))
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -276,7 +262,7 @@ class IFC2CA:
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"ifcName": item.is_a() + "|" + str(item.id()),
|
"ifcName": f"{item.is_a()}|{item.id()}",
|
||||||
"name": item.Name,
|
"name": item.Name,
|
||||||
"id": item.GlobalId,
|
"id": item.GlobalId,
|
||||||
"geometryType": "line",
|
"geometryType": "line",
|
||||||
@@ -284,8 +270,7 @@ class IFC2CA:
|
|||||||
"orientation": orientation,
|
"orientation": orientation,
|
||||||
"appliedCondition": self.get_connection_input(item, "line"),
|
"appliedCondition": self.get_connection_input(item, "line"),
|
||||||
"relatedElements": [
|
"relatedElements": [
|
||||||
con.is_a() + "|" + str(con.id())
|
f"{con.is_a()}|{con.id()}" for con in item.ConnectsStructuralMembers
|
||||||
for con in item.ConnectsStructuralMembers
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,9 +321,7 @@ class IFC2CA:
|
|||||||
if not element.Representation:
|
if not element.Representation:
|
||||||
return None
|
return None
|
||||||
for representation in element.Representation.Representations:
|
for representation in element.Representation.Representations:
|
||||||
rep = self.get_specific_representation(
|
rep = self.get_specific_representation(representation, "Reference", rep_type)
|
||||||
representation, "Reference", rep_type
|
|
||||||
)
|
|
||||||
if rep:
|
if rep:
|
||||||
return rep
|
return rep
|
||||||
else:
|
else:
|
||||||
@@ -419,9 +402,13 @@ class IFC2CA:
|
|||||||
def get_2D_orientation(self, representation):
|
def get_2D_orientation(self, representation):
|
||||||
item = representation.Items[0]
|
item = representation.Items[0]
|
||||||
if item.is_a("IfcFaceSurface"):
|
if item.is_a("IfcFaceSurface"):
|
||||||
item.SameSense
|
|
||||||
axes = item.FaceSurface.Position
|
axes = item.FaceSurface.Position
|
||||||
orientation = self.get_0D_orientation(axes)
|
orientation = self.get_0D_orientation(axes)
|
||||||
|
if not orientation:
|
||||||
|
self.warnings.append(
|
||||||
|
f"No local placement for Plane related to {item.is_a()}|{item.id()}. A unit orientation is considered"
|
||||||
|
)
|
||||||
|
return np.eye(3).tolist()
|
||||||
if not item.SameSense:
|
if not item.SameSense:
|
||||||
orientation = [[-v for v in vec] for vec in orientation]
|
orientation = [[-v for v in vec] for vec in orientation]
|
||||||
return orientation
|
return orientation
|
||||||
@@ -516,7 +503,7 @@ class IFC2CA:
|
|||||||
mechProps = self.get_i_section_properties(profile, "iSymmetrical")
|
mechProps = self.get_i_section_properties(profile, "iSymmetrical")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"ifcName": profile.is_a() + "|" + str(profile.id()),
|
"ifcName": f"{profile.is_a()}|{profile.id()}",
|
||||||
"profileName": profile.ProfileName,
|
"profileName": profile.ProfileName,
|
||||||
"profileType": profile.ProfileType,
|
"profileType": profile.ProfileType,
|
||||||
"profileShape": "iSymmetrical",
|
"profileShape": "iSymmetrical",
|
||||||
@@ -533,14 +520,10 @@ class IFC2CA:
|
|||||||
def get_connection_data(self, itemList):
|
def get_connection_data(self, itemList):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"ifcName": rel.is_a() + "|" + str(rel.id()),
|
"ifcName": f"{rel.is_a()}|{rel.id()}",
|
||||||
"id": rel.GlobalId,
|
"id": rel.GlobalId,
|
||||||
"relatingElement": rel.RelatingStructuralMember.is_a()
|
"relatingElement": f"{rel.RelatingStructuralMember.is_a()}|{rel.RelatingStructuralMember.id()}",
|
||||||
+ "|"
|
"relatedConnection": f"{rel.RelatedStructuralConnection.is_a()}|{rel.RelatedStructuralConnection.id()}",
|
||||||
+ str(rel.RelatingStructuralMember.id()),
|
|
||||||
"relatedConnection": rel.RelatedStructuralConnection.is_a()
|
|
||||||
+ "|"
|
|
||||||
+ str(rel.RelatedStructuralConnection.id()),
|
|
||||||
"orientation": self.get_0D_orientation(rel.ConditionCoordinateSystem),
|
"orientation": self.get_0D_orientation(rel.ConditionCoordinateSystem),
|
||||||
"appliedCondition": self.get_connection_input(
|
"appliedCondition": self.get_connection_input(
|
||||||
rel,
|
rel,
|
||||||
@@ -641,8 +624,10 @@ if __name__ == "__main__":
|
|||||||
files = fileNames
|
files = fileNames
|
||||||
|
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
BASE_PATH = "/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/ifcFiles/"
|
BASE_PATH = Path(
|
||||||
ifc2ca = IFC2CA(BASE_PATH + fileName + ".ifc")
|
"/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/ifcFiles/"
|
||||||
|
)
|
||||||
|
ifc2ca = IFC2CA(BASE_PATH / f"{fileName}.ifc")
|
||||||
ifc2ca.convert()
|
ifc2ca.convert()
|
||||||
with open(BASE_PATH + fileName + ".json", "w") as f:
|
with open(BASE_PATH / f"{fileName}.json", "w") as f:
|
||||||
f.write(json.dumps(ifc2ca.result, indent=4))
|
f.write(json.dumps(ifc2ca.result, indent=4))
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# Ifc2CA - IFC Code_Aster utility
|
# Ifc2CA - IFC Code_Aster utility
|
||||||
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
|
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
|
||||||
#
|
#
|
||||||
@@ -20,6 +19,7 @@
|
|||||||
import json
|
import json
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools
|
import itertools
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
flatten = itertools.chain.from_iterable
|
flatten = itertools.chain.from_iterable
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ class COMMANDFILE:
|
|||||||
def getGroupName(self, name):
|
def getGroupName(self, name):
|
||||||
info = name.split("|")
|
info = name.split("|")
|
||||||
sortName = "".join(c for c in info[0] if c.isupper())
|
sortName = "".join(c for c in info[0] if c.isupper())
|
||||||
return str(sortName + "_" + info[1])
|
return f"{sortName[2:]}_{info[1]}"
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
|
|
||||||
@@ -1083,7 +1083,9 @@ if __name__ == "__main__":
|
|||||||
files = fileNames
|
files = fileNames
|
||||||
|
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
BASE_PATH = "/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/models/"
|
BASE_PATH = Path(
|
||||||
DATAFILENAME = BASE_PATH + fileName + "/" + fileName + ".json"
|
"/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/models/"
|
||||||
ASTERFILENAME = BASE_PATH + fileName + "/" + fileName + ".comm"
|
)
|
||||||
|
DATAFILENAME = BASE_PATH / fileName / f"{fileName}.json"
|
||||||
|
ASTERFILENAME = BASE_PATH / fileName / f"{fileName}.comm"
|
||||||
COMMANDFILE(DATAFILENAME, ASTERFILENAME)
|
COMMANDFILE(DATAFILENAME, ASTERFILENAME)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# Ifc2CA - IFC Code_Aster utility
|
# Ifc2CA - IFC Code_Aster utility
|
||||||
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
|
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
|
||||||
#
|
#
|
||||||
@@ -20,6 +19,7 @@
|
|||||||
import json
|
import json
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools
|
import itertools
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
flatten = itertools.chain.from_iterable
|
flatten = itertools.chain.from_iterable
|
||||||
|
|
||||||
@@ -27,6 +27,7 @@ ScaleFactor = 1.0
|
|||||||
|
|
||||||
AccelOfGravity = 9.806 * 1000
|
AccelOfGravity = 9.806 * 1000
|
||||||
|
|
||||||
|
|
||||||
class COMMANDFILE:
|
class COMMANDFILE:
|
||||||
def __init__(self, dataFilename, asterFilename):
|
def __init__(self, dataFilename, asterFilename):
|
||||||
self.dataFilename = dataFilename
|
self.dataFilename = dataFilename
|
||||||
@@ -36,7 +37,7 @@ class COMMANDFILE:
|
|||||||
def getGroupName(self, name):
|
def getGroupName(self, name):
|
||||||
info = name.split("|")
|
info = name.split("|")
|
||||||
sortName = "".join(c for c in info[0] if c.isupper())
|
sortName = "".join(c for c in info[0] if c.isupper())
|
||||||
return str(sortName + "_" + info[1])
|
return f"{sortName[2:]}_{info[1]}"
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
# Read data from input file
|
# Read data from input file
|
||||||
@@ -568,7 +569,9 @@ if __name__ == "__main__":
|
|||||||
files = fileNames
|
files = fileNames
|
||||||
|
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
BASE_PATH = "/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/models/"
|
BASE_PATH = Path(
|
||||||
DATAFILENAME = BASE_PATH + fileName + "/" + fileName + ".json"
|
"/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/models/"
|
||||||
ASTERFILENAME = BASE_PATH + fileName + "/" + fileName + ".comm"
|
)
|
||||||
|
DATAFILENAME = BASE_PATH / fileName / f"{fileName}.json"
|
||||||
|
ASTERFILENAME = BASE_PATH / fileName / f"{fileName}.comm"
|
||||||
COMMANDFILE(DATAFILENAME, ASTERFILENAME)
|
COMMANDFILE(DATAFILENAME, ASTERFILENAME)
|
||||||
|
|||||||
+15
-16
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# Ifc2CA - IFC Code_Aster utility
|
# Ifc2CA - IFC Code_Aster utility
|
||||||
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
|
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
|
||||||
#
|
#
|
||||||
@@ -27,6 +26,7 @@ import salome_notebook
|
|||||||
import salome_version
|
import salome_version
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools
|
import itertools
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
flatten = itertools.chain.from_iterable
|
flatten = itertools.chain.from_iterable
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ class MODEL:
|
|||||||
def getGroupName(self, name):
|
def getGroupName(self, name):
|
||||||
info = name.split("|")
|
info = name.split("|")
|
||||||
sortName = "".join(c for c in info[0] if c.isupper())
|
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):
|
def makePoint(self, pl):
|
||||||
"""Function to define a Point from
|
"""Function to define a Point from
|
||||||
@@ -212,15 +212,14 @@ class MODEL:
|
|||||||
"Eccentricity defined for a %s geometryType"
|
"Eccentricity defined for a %s geometryType"
|
||||||
% conn["geometryType"]
|
% conn["geometryType"]
|
||||||
)
|
)
|
||||||
|
|
||||||
el["partObj"] = self.makePartition(
|
el["partObj"] = self.makePartition(
|
||||||
[el["elemObj"]] + el["connObjs"], el["geometryType"]
|
[el["elemObj"]] + el["connObjs"], el["geometryType"]
|
||||||
)
|
)
|
||||||
|
el["elemObj"] = geompy.GetInPlace(el["partObj"], el["elemObj"], True)
|
||||||
el["elemObj"] = geompy.GetInPlace(el["partObj"], el["elemObj"])
|
|
||||||
for j, rel in enumerate(el["connections"]):
|
for j, rel in enumerate(el["connections"]):
|
||||||
el["connObjs"][j] = geompy.GetInPlace(el["partObj"], el["connObjs"][j])
|
el["connObjs"][j] = geompy.GetInPlace(
|
||||||
|
el["partObj"], el["connObjs"][j], True
|
||||||
|
)
|
||||||
for conn in connections:
|
for conn in connections:
|
||||||
conn["connObj"] = self.makeObject(conn["geometry"], conn["geometryType"])
|
conn["connObj"] = self.makeObject(conn["geometry"], conn["geometryType"])
|
||||||
|
|
||||||
@@ -283,7 +282,7 @@ class MODEL:
|
|||||||
[e["elemObj"] for e in elements if e["geometryType"] == "line"]
|
[e["elemObj"] for e in elements if e["geometryType"] == "line"]
|
||||||
)
|
)
|
||||||
# Define group object and add to study
|
# Define group object and add to study
|
||||||
curveCompound = geompy.GetInPlace(bldComp, compoundTemp)
|
curveCompound = geompy.GetInPlace(bldComp, compoundTemp, True)
|
||||||
geompy.addToStudyInFather(bldComp, curveCompound, "CurveMembers")
|
geompy.addToStudyInFather(bldComp, curveCompound, "CurveMembers")
|
||||||
|
|
||||||
if len([e for e in elements if e["geometryType"] == "surface"]) > 0:
|
if len([e for e in elements if e["geometryType"] == "surface"]) > 0:
|
||||||
@@ -292,7 +291,7 @@ class MODEL:
|
|||||||
[e["elemObj"] for e in elements if e["geometryType"] == "surface"]
|
[e["elemObj"] for e in elements if e["geometryType"] == "surface"]
|
||||||
)
|
)
|
||||||
# Define group object and add to study
|
# Define group object and add to study
|
||||||
surfaceCompound = geompy.GetInPlace(bldComp, compoundTemp)
|
surfaceCompound = geompy.GetInPlace(bldComp, compoundTemp, True)
|
||||||
geompy.addToStudyInFather(bldComp, surfaceCompound, "SurfaceMembers")
|
geompy.addToStudyInFather(bldComp, surfaceCompound, "SurfaceMembers")
|
||||||
|
|
||||||
# Loop 3
|
# Loop 3
|
||||||
@@ -393,9 +392,7 @@ class MODEL:
|
|||||||
smesh.SetName(tempgroup, "CurveMembers")
|
smesh.SetName(tempgroup, "CurveMembers")
|
||||||
|
|
||||||
if len([e for e in elements if e["geometryType"] == "surface"]) > 0:
|
if len([e for e in elements if e["geometryType"] == "surface"]) > 0:
|
||||||
tempgroup = bldMesh.GroupOnGeom(
|
tempgroup = bldMesh.GroupOnGeom(surfaceCompound, "SurfaceMembers", SMESH.FACE)
|
||||||
surfaceCompound, "SurfaceMembers", SMESH.FACE
|
|
||||||
)
|
|
||||||
smesh.SetName(tempgroup, "SurfaceMembers")
|
smesh.SetName(tempgroup, "SurfaceMembers")
|
||||||
|
|
||||||
# Define groups in Mesh
|
# Define groups in Mesh
|
||||||
@@ -562,7 +559,9 @@ if __name__ == "__main__":
|
|||||||
meshSize = 0.1
|
meshSize = 0.1
|
||||||
|
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
BASE_PATH = "/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/models/"
|
BASE_PATH = Path(
|
||||||
DATAFILENAME = BASE_PATH + fileName + "/" + fileName + ".json"
|
"/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/models/"
|
||||||
MEDFILENAME = BASE_PATH + fileName + "/" + fileName + ".med"
|
)
|
||||||
model = MODEL(DATAFILENAME, MEDFILENAME, meshSize)
|
DATAFILENAME = BASE_PATH / fileName / f"{fileName}.json"
|
||||||
|
MEDFILENAME = BASE_PATH / fileName / f"{fileName}.med"
|
||||||
|
model = MODEL(DATAFILENAME, str(MEDFILENAME), meshSize)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# Ifc2CA - IFC Code_Aster utility
|
# Ifc2CA - IFC Code_Aster utility
|
||||||
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
|
# Copyright (C) 2020, 2021 Ioannis P. Christovasilis <ipc@aethereng.com>
|
||||||
#
|
#
|
||||||
@@ -27,6 +26,7 @@ import salome_notebook
|
|||||||
import salome_version
|
import salome_version
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools
|
import itertools
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
flatten = itertools.chain.from_iterable
|
flatten = itertools.chain.from_iterable
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class MODEL:
|
|||||||
def getGroupName(self, name):
|
def getGroupName(self, name):
|
||||||
info = name.split("|")
|
info = name.split("|")
|
||||||
sortName = "".join(c for c in info[0] if c.isupper())
|
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):
|
def makePoint(self, pl):
|
||||||
"""Function to define a Point from
|
"""Function to define a Point from
|
||||||
@@ -234,7 +234,7 @@ class MODEL:
|
|||||||
[e["elemObj"] for e in elements if e["geometryType"] == "line"]
|
[e["elemObj"] for e in elements if e["geometryType"] == "line"]
|
||||||
)
|
)
|
||||||
# Define group object and add to study
|
# Define group object and add to study
|
||||||
curveCompound = geompy.GetInPlace(bldComp, compoundTemp)
|
curveCompound = geompy.GetInPlace(bldComp, compoundTemp, True)
|
||||||
geompy.addToStudyInFather(bldComp, curveCompound, "CurveMembers")
|
geompy.addToStudyInFather(bldComp, curveCompound, "CurveMembers")
|
||||||
|
|
||||||
if len([e for e in elements if e["geometryType"] == "surface"]) > 0:
|
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"]
|
[e["elemObj"] for e in elements if e["geometryType"] == "surface"]
|
||||||
)
|
)
|
||||||
# Define group object and add to study
|
# Define group object and add to study
|
||||||
surfaceCompound = geompy.GetInPlace(bldComp, compoundTemp)
|
surfaceCompound = geompy.GetInPlace(bldComp, compoundTemp, True)
|
||||||
geompy.addToStudyInFather(bldComp, surfaceCompound, "SurfaceMembers")
|
geompy.addToStudyInFather(bldComp, surfaceCompound, "SurfaceMembers")
|
||||||
|
|
||||||
linkObjs = list(
|
linkObjs = list(
|
||||||
@@ -253,19 +253,21 @@ class MODEL:
|
|||||||
# Make compound of requested group
|
# Make compound of requested group
|
||||||
compoundTemp = geompy.MakeCompound(linkObjs)
|
compoundTemp = geompy.MakeCompound(linkObjs)
|
||||||
# Define group object and add to study
|
# Define group object and add to study
|
||||||
rigidCompound = geompy.GetInPlace(bldComp, compoundTemp)
|
rigidCompound = geompy.GetInPlace(bldComp, compoundTemp, True)
|
||||||
geompy.addToStudyInFather(bldComp, rigidCompound, "RigidMembers")
|
geompy.addToStudyInFather(bldComp, rigidCompound, "RigidMembers")
|
||||||
|
|
||||||
for el in elements:
|
for el in elements:
|
||||||
# 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"])
|
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["ifcName"])
|
||||||
)
|
)
|
||||||
|
|
||||||
for j, rel in enumerate(el["connections"]):
|
for j, rel in enumerate(el["connections"]):
|
||||||
if rel["eccentricity"]: # point geometry
|
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(
|
geompy.addToStudyInFather(
|
||||||
bldComp,
|
bldComp,
|
||||||
el["linkObjs"][j],
|
el["linkObjs"][j],
|
||||||
@@ -337,9 +339,7 @@ class MODEL:
|
|||||||
smesh.SetName(tempgroup, "CurveMembers")
|
smesh.SetName(tempgroup, "CurveMembers")
|
||||||
|
|
||||||
if len([e for e in elements if e["geometryType"] == "surface"]) > 0:
|
if len([e for e in elements if e["geometryType"] == "surface"]) > 0:
|
||||||
tempgroup = bldMesh.GroupOnGeom(
|
tempgroup = bldMesh.GroupOnGeom(surfaceCompound, "SurfaceMembers", SMESH.FACE)
|
||||||
surfaceCompound, "SurfaceMembers", SMESH.FACE
|
|
||||||
)
|
|
||||||
smesh.SetName(tempgroup, "SurfaceMembers")
|
smesh.SetName(tempgroup, "SurfaceMembers")
|
||||||
|
|
||||||
if len(linkObjs) > 0:
|
if len(linkObjs) > 0:
|
||||||
@@ -423,7 +423,9 @@ if __name__ == "__main__":
|
|||||||
zGround = 0
|
zGround = 0
|
||||||
|
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
BASE_PATH = "/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/models/"
|
BASE_PATH = Path(
|
||||||
DATAFILENAME = BASE_PATH + fileName + "/" + fileName + ".json"
|
"/home/jesusbill/Dev-Projects/github.com/IfcOpenShell/analysis-models/models/"
|
||||||
MEDFILENAME = BASE_PATH + fileName + "/" + fileName + ".med"
|
)
|
||||||
model = MODEL(DATAFILENAME, MEDFILENAME, meshSize, zGround)
|
DATAFILENAME = BASE_PATH / fileName / f"{fileName}.json"
|
||||||
|
MEDFILENAME = BASE_PATH / fileName / f"{fileName}.med"
|
||||||
|
model = MODEL(DATAFILENAME, str(MEDFILENAME), meshSize, zGround)
|
||||||
|
|||||||
Reference in New Issue
Block a user