#2342 Support different IFC schema versions for obj2ifc

This commit is contained in:
Dion Moult
2022-08-18 17:15:39 +10:00
parent 09a6f56f47
commit 836a162d57
2 changed files with 10 additions and 10 deletions
+5 -5
View File
@@ -30,9 +30,9 @@ class Obj2Ifc:
def __init__(self, path):
self.path = path
def execute(self):
def execute(self, version="IFC4"):
self.basename = Path(self.path).stem
self.create_ifc_file()
self.create_ifc_file(version)
mesh_set = pymeshlab.MeshSet()
mesh_set.load_new_mesh(self.path)
@@ -87,10 +87,10 @@ class Obj2Ifc:
# OBJ swaps Y and Z axis
return [coordinates[0], -coordinates[2], coordinates[1]]
def create_ifc_file(self):
self.file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
def create_ifc_file(self, version):
self.file = ifcopenshell.api.run("project.create_file", version=version)
person = ifcopenshell.api.run("owner.add_person", self.file)
person.Id = person.GivenName = None
person[0] = person.GivenName = None
person.FamilyName = "user"
org = ifcopenshell.api.run("owner.add_organisation", self.file)
org.Id = None
+5 -5
View File
@@ -30,9 +30,9 @@ class Obj2Ifc:
def __init__(self, path):
self.path = path
def execute(self):
def execute(self, version="IFC4"):
self.basename = Path(self.path).stem
self.create_ifc_file()
self.create_ifc_file(version)
self.scene = pywavefront.Wavefront(self.path, create_materials=True, collect_faces=True)
for mesh in self.scene.mesh_list:
ifc_faces = []
@@ -73,10 +73,10 @@ class Obj2Ifc:
ifcopenshell.api.run("spatial.assign_container", self.file, product=product, relating_structure=self.storey)
self.file.write(self.path.replace(".obj", ".ifc"))
def create_ifc_file(self):
self.file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
def create_ifc_file(self, version):
self.file = ifcopenshell.api.run("project.create_file", version=version)
person = ifcopenshell.api.run("owner.add_person", self.file)
person.Id = person.GivenName = None
person[0] = person.GivenName = None
person.FamilyName = "user"
org = ifcopenshell.api.run("owner.add_organisation", self.file)
org.Id = None