Skip to content

Commit a038ae4

Browse files
committed
ifccityjson: it is now easier to extract one LOD
1 parent 698ef40 commit a038ae4

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/ifccityjson/cityjson2ifc.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ def __init__(self):
7777
self.geometry = GeometryIO()
7878
self.configuration()
7979

80-
def configuration(self, file_destination="output.ifc", name_attribute=None, split=True):
80+
def configuration(self, file_destination="output.ifc", name_attribute=None, split=True, lod=None):
8181
self.properties["file_destination"], self.properties["file_extension"] = os.path.splitext(file_destination)
8282
self.properties["name_attribute"] = name_attribute
8383
self.properties["split"] = split
84+
self.properties["lod"] = lod
8485

8586
def convert(self, city_model):
8687
self.city_model = city_model
@@ -92,7 +93,9 @@ def convert(self, city_model):
9293
# scale=self.properties["local_scale"])
9394
# self.build_vertices()
9495
self.create_IFC_classes()
95-
if self.properties["split"]:
96+
if self.properties["lod"]:
97+
self.write_file()
98+
elif self.properties["split"]:
9699
self.write_files()
97100
else:
98101
self.write_file()
@@ -190,7 +193,6 @@ def write_files(self):
190193
IFC_copied_model = ifcopenshell.open(file)
191194
IFC_copied_model_sub_contexts = IFC_copied_model.by_type('IfcGeometricRepresentationSubContext')
192195
for sub_context in IFC_copied_model_sub_contexts:
193-
print(sub_context)
194196
if sub_context.id() == sub_context_id:
195197
continue
196198

@@ -230,7 +232,7 @@ def create_IFC_classes(self):
230232
IFC_shape_representations = []
231233
for geometry in obj.geometry:
232234
lod = geometry.lod
233-
if str(lod) != '1.3': # TODO: split LODS
235+
if self.properties["lod"] is not None and str(lod) != self.properties["lod"]:
234236
continue
235237
if str(lod) not in self.IFC_representation_sub_contexts:
236238
self.IFC_representation_sub_contexts[str(lod)] = self.create_representation_sub_context(lod)

src/ifccityjson/ifccityjson.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
help="Split the file in multiple LoDs")
3434
parser.add_argument('--no-split-lod', dest='split', action='store_false',
3535
help="Do not split the file in multiple LoDs")
36+
parser.add_argument("--lod", type=str, help="extract LOD value (example: 1.2)")
3637
parser.set_defaults(split=True)
3738
args = parser.parse_args()
3839

@@ -42,6 +43,8 @@
4243
data["name_attribute"] = args.name
4344
if args.output:
4445
data["file_destination"] = args.output
46+
if args.lod:
47+
data["lod"] = args.lod
4548
data["split"] = args.split
4649

4750
converter = Cityjson2ifc()

0 commit comments

Comments
 (0)