Skip to content

Commit 836a162

Browse files
committed
IfcOpenShell#2342 Support different IFC schema versions for obj2ifc
1 parent 09a6f56 commit 836a162

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/blenderbim/scripts/obj2ifc-meshlab.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class Obj2Ifc:
3030
def __init__(self, path):
3131
self.path = path
3232

33-
def execute(self):
33+
def execute(self, version="IFC4"):
3434
self.basename = Path(self.path).stem
35-
self.create_ifc_file()
35+
self.create_ifc_file(version)
3636
mesh_set = pymeshlab.MeshSet()
3737
mesh_set.load_new_mesh(self.path)
3838

@@ -87,10 +87,10 @@ def get_coordinates(self, coordinates):
8787
# OBJ swaps Y and Z axis
8888
return [coordinates[0], -coordinates[2], coordinates[1]]
8989

90-
def create_ifc_file(self):
91-
self.file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
90+
def create_ifc_file(self, version):
91+
self.file = ifcopenshell.api.run("project.create_file", version=version)
9292
person = ifcopenshell.api.run("owner.add_person", self.file)
93-
person.Id = person.GivenName = None
93+
person[0] = person.GivenName = None
9494
person.FamilyName = "user"
9595
org = ifcopenshell.api.run("owner.add_organisation", self.file)
9696
org.Id = None

src/blenderbim/scripts/obj2ifc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class Obj2Ifc:
3030
def __init__(self, path):
3131
self.path = path
3232

33-
def execute(self):
33+
def execute(self, version="IFC4"):
3434
self.basename = Path(self.path).stem
35-
self.create_ifc_file()
35+
self.create_ifc_file(version)
3636
self.scene = pywavefront.Wavefront(self.path, create_materials=True, collect_faces=True)
3737
for mesh in self.scene.mesh_list:
3838
ifc_faces = []
@@ -73,10 +73,10 @@ def execute(self):
7373
ifcopenshell.api.run("spatial.assign_container", self.file, product=product, relating_structure=self.storey)
7474
self.file.write(self.path.replace(".obj", ".ifc"))
7575

76-
def create_ifc_file(self):
77-
self.file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
76+
def create_ifc_file(self, version):
77+
self.file = ifcopenshell.api.run("project.create_file", version=version)
7878
person = ifcopenshell.api.run("owner.add_person", self.file)
79-
person.Id = person.GivenName = None
79+
person[0] = person.GivenName = None
8080
person.FamilyName = "user"
8181
org = ifcopenshell.api.run("owner.add_organisation", self.file)
8282
org.Id = None

0 commit comments

Comments
 (0)