mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 16:22:53 +00:00
ifccityjson: it is now easier to extract one LOD
This commit is contained in:
@@ -77,10 +77,11 @@ class Cityjson2ifc:
|
|||||||
self.geometry = GeometryIO()
|
self.geometry = GeometryIO()
|
||||||
self.configuration()
|
self.configuration()
|
||||||
|
|
||||||
def configuration(self, file_destination="output.ifc", name_attribute=None, split=True):
|
def configuration(self, file_destination="output.ifc", name_attribute=None, split=True, lod=None):
|
||||||
self.properties["file_destination"], self.properties["file_extension"] = os.path.splitext(file_destination)
|
self.properties["file_destination"], self.properties["file_extension"] = os.path.splitext(file_destination)
|
||||||
self.properties["name_attribute"] = name_attribute
|
self.properties["name_attribute"] = name_attribute
|
||||||
self.properties["split"] = split
|
self.properties["split"] = split
|
||||||
|
self.properties["lod"] = lod
|
||||||
|
|
||||||
def convert(self, city_model):
|
def convert(self, city_model):
|
||||||
self.city_model = city_model
|
self.city_model = city_model
|
||||||
@@ -92,7 +93,9 @@ class Cityjson2ifc:
|
|||||||
# scale=self.properties["local_scale"])
|
# scale=self.properties["local_scale"])
|
||||||
# self.build_vertices()
|
# self.build_vertices()
|
||||||
self.create_IFC_classes()
|
self.create_IFC_classes()
|
||||||
if self.properties["split"]:
|
if self.properties["lod"]:
|
||||||
|
self.write_file()
|
||||||
|
elif self.properties["split"]:
|
||||||
self.write_files()
|
self.write_files()
|
||||||
else:
|
else:
|
||||||
self.write_file()
|
self.write_file()
|
||||||
@@ -190,7 +193,6 @@ class Cityjson2ifc:
|
|||||||
IFC_copied_model = ifcopenshell.open(file)
|
IFC_copied_model = ifcopenshell.open(file)
|
||||||
IFC_copied_model_sub_contexts = IFC_copied_model.by_type('IfcGeometricRepresentationSubContext')
|
IFC_copied_model_sub_contexts = IFC_copied_model.by_type('IfcGeometricRepresentationSubContext')
|
||||||
for sub_context in IFC_copied_model_sub_contexts:
|
for sub_context in IFC_copied_model_sub_contexts:
|
||||||
print(sub_context)
|
|
||||||
if sub_context.id() == sub_context_id:
|
if sub_context.id() == sub_context_id:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -230,7 +232,7 @@ class Cityjson2ifc:
|
|||||||
IFC_shape_representations = []
|
IFC_shape_representations = []
|
||||||
for geometry in obj.geometry:
|
for geometry in obj.geometry:
|
||||||
lod = geometry.lod
|
lod = geometry.lod
|
||||||
if str(lod) != '1.3': # TODO: split LODS
|
if self.properties["lod"] is not None and str(lod) != self.properties["lod"]:
|
||||||
continue
|
continue
|
||||||
if str(lod) not in self.IFC_representation_sub_contexts:
|
if str(lod) not in self.IFC_representation_sub_contexts:
|
||||||
self.IFC_representation_sub_contexts[str(lod)] = self.create_representation_sub_context(lod)
|
self.IFC_representation_sub_contexts[str(lod)] = self.create_representation_sub_context(lod)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ if __name__ == '__main__':
|
|||||||
help="Split the file in multiple LoDs")
|
help="Split the file in multiple LoDs")
|
||||||
parser.add_argument('--no-split-lod', dest='split', action='store_false',
|
parser.add_argument('--no-split-lod', dest='split', action='store_false',
|
||||||
help="Do not split the file in multiple LoDs")
|
help="Do not split the file in multiple LoDs")
|
||||||
|
parser.add_argument("--lod", type=str, help="extract LOD value (example: 1.2)")
|
||||||
parser.set_defaults(split=True)
|
parser.set_defaults(split=True)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -42,6 +43,8 @@ if __name__ == '__main__':
|
|||||||
data["name_attribute"] = args.name
|
data["name_attribute"] = args.name
|
||||||
if args.output:
|
if args.output:
|
||||||
data["file_destination"] = args.output
|
data["file_destination"] = args.output
|
||||||
|
if args.lod:
|
||||||
|
data["lod"] = args.lod
|
||||||
data["split"] = args.split
|
data["split"] = args.split
|
||||||
|
|
||||||
converter = Cityjson2ifc()
|
converter = Cityjson2ifc()
|
||||||
|
|||||||
Reference in New Issue
Block a user