Skip to content

Commit 2154460

Browse files
Small improvements for usage as module
1 parent adfcc86 commit 2154460

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

ifc2json.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# IFCJSON_python - ifc2json.py
2-
# Convert IFC SPF file to IFC.JSON-4
2+
# Convert IFC SPF file to IFC.JSON
33
# https://github.com/IFCJSON-Team
44

55
# MIT License
@@ -28,8 +28,7 @@
2828
import os
2929
import argparse
3030
import json
31-
from ifcjson.ifc2json4 import IFC2JSON4
32-
from ifcjson.ifc2json5a import IFC2JSON5a
31+
import ifcjson
3332
t1_start = perf_counter()
3433

3534
if __name__ == '__main__':
@@ -48,11 +47,11 @@
4847
else:
4948
jsonFilePath = os.path.splitext(ifcFilePath)[0] + '.json'
5049
if not args.v or args.v == "4":
51-
jsonData = IFC2JSON4(ifcFilePath).spf2Json()
50+
jsonData = ifcjson.IFC2JSON4(ifcFilePath).spf2Json()
5251
with open(jsonFilePath, 'w') as outfile:
5352
json.dump(jsonData, outfile, indent=4)
5453
elif args.v == "5a":
55-
jsonData = IFC2JSON5a(ifcFilePath).spf2Json()
54+
jsonData = ifcjson.IFC2JSON5a(ifcFilePath).spf2Json()
5655
with open(jsonFilePath, 'w') as outfile:
5756
json.dump(jsonData, outfile, indent=4)
5857
else:

ifcjson/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from ifcjson.ifc2json4 import IFC2JSON4
2+
from ifcjson.ifc2json5a import IFC2JSON5a

ifcjson/ifc2json5a.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def entityToDict(self, entity, objData, parent=None):
213213
if attr in entityAttributes:
214214

215215
# Skip all IFC entities that are not part of IFC.JSON5a
216-
if type(entityAttributes[attr]) == ifcopenshell.entity_instance:
216+
if isinstance(entityAttributes[attr], ifcopenshell.entity_instance):
217217

218218
# Skip IfcOwnerHistory
219219
if entityAttributes[attr].is_a() == 'IfcOwnerHistory':

0 commit comments

Comments
 (0)