Skip to content

Commit 884e8a5

Browse files
committed
Fix IfcOpenShell#1071. New IFC file version 2X3<->4 upgrader and downgrader IfcPatch recipe
1 parent 06685f9 commit 884e8a5

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

src/ifcblenderexport/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ endif
296296
cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/__init__.py
297297
cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/ExtractElements.py
298298
cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/MergeProject.py
299+
cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/Migrate.py
299300
cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/OffsetObjectPlacements.py
300301
cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/OffsetStoreyElevations.py
301302
cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/Optimise.py

src/ifcopenshell-python/ifcopenshell/util/schema.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,3 @@ def generate_default_value(self, attribute, new_file):
201201
}
202202
)
203203
return self.default_entities[attribute.name()]
204-
205-
206-
# f = ifcopenshell.open("/home/dion/migrate.ifc")
207-
# g = ifcopenshell.file(schema="IFC4")
208-
# migrator = Migrator()
209-
# for e in f:
210-
# print(e)
211-
# print(migrator.migrate(e, g))
212-
# g.write("/home/dion/migrate2.ifc")

src/ifcpatch/recipes/Migrate.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import ifcopenshell
2+
import ifcopenshell.util.schema
3+
4+
5+
class Patcher:
6+
def __init__(self, src, file, logger, args=None):
7+
self.src = src
8+
self.file = file
9+
self.logger = logger
10+
self.args = args
11+
12+
def patch(self):
13+
self.new = ifcopenshell.file(schema=self.args[0])
14+
migrator = ifcopenshell.util.schema.Migrator()
15+
for element in self.file:
16+
print("Migrating", element)
17+
print("Successfully converted to", migrator.migrate(element, self.new))
18+
self.file = self.new

0 commit comments

Comments
 (0)