mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 01:47:55 +00:00
#2342 Support different IFC schema versions for obj2ifc
This commit is contained in:
@@ -30,9 +30,9 @@ class Obj2Ifc:
|
|||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
def execute(self):
|
def execute(self, version="IFC4"):
|
||||||
self.basename = Path(self.path).stem
|
self.basename = Path(self.path).stem
|
||||||
self.create_ifc_file()
|
self.create_ifc_file(version)
|
||||||
mesh_set = pymeshlab.MeshSet()
|
mesh_set = pymeshlab.MeshSet()
|
||||||
mesh_set.load_new_mesh(self.path)
|
mesh_set.load_new_mesh(self.path)
|
||||||
|
|
||||||
@@ -87,10 +87,10 @@ class Obj2Ifc:
|
|||||||
# OBJ swaps Y and Z axis
|
# OBJ swaps Y and Z axis
|
||||||
return [coordinates[0], -coordinates[2], coordinates[1]]
|
return [coordinates[0], -coordinates[2], coordinates[1]]
|
||||||
|
|
||||||
def create_ifc_file(self):
|
def create_ifc_file(self, version):
|
||||||
self.file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
|
self.file = ifcopenshell.api.run("project.create_file", version=version)
|
||||||
person = ifcopenshell.api.run("owner.add_person", self.file)
|
person = ifcopenshell.api.run("owner.add_person", self.file)
|
||||||
person.Id = person.GivenName = None
|
person[0] = person.GivenName = None
|
||||||
person.FamilyName = "user"
|
person.FamilyName = "user"
|
||||||
org = ifcopenshell.api.run("owner.add_organisation", self.file)
|
org = ifcopenshell.api.run("owner.add_organisation", self.file)
|
||||||
org.Id = None
|
org.Id = None
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ class Obj2Ifc:
|
|||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
def execute(self):
|
def execute(self, version="IFC4"):
|
||||||
self.basename = Path(self.path).stem
|
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)
|
self.scene = pywavefront.Wavefront(self.path, create_materials=True, collect_faces=True)
|
||||||
for mesh in self.scene.mesh_list:
|
for mesh in self.scene.mesh_list:
|
||||||
ifc_faces = []
|
ifc_faces = []
|
||||||
@@ -73,10 +73,10 @@ class Obj2Ifc:
|
|||||||
ifcopenshell.api.run("spatial.assign_container", self.file, product=product, relating_structure=self.storey)
|
ifcopenshell.api.run("spatial.assign_container", self.file, product=product, relating_structure=self.storey)
|
||||||
self.file.write(self.path.replace(".obj", ".ifc"))
|
self.file.write(self.path.replace(".obj", ".ifc"))
|
||||||
|
|
||||||
def create_ifc_file(self):
|
def create_ifc_file(self, version):
|
||||||
self.file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
|
self.file = ifcopenshell.api.run("project.create_file", version=version)
|
||||||
person = ifcopenshell.api.run("owner.add_person", self.file)
|
person = ifcopenshell.api.run("owner.add_person", self.file)
|
||||||
person.Id = person.GivenName = None
|
person[0] = person.GivenName = None
|
||||||
person.FamilyName = "user"
|
person.FamilyName = "user"
|
||||||
org = ifcopenshell.api.run("owner.add_organisation", self.file)
|
org = ifcopenshell.api.run("owner.add_organisation", self.file)
|
||||||
org.Id = None
|
org.Id = None
|
||||||
|
|||||||
Reference in New Issue
Block a user