Integrate ifccityjson in BlenderBIM (#1859)

* ifccityjson-BB integration: include CJIO in makefile

* Add ifccityjson to BlenderBIM

* Make ifccityjson work like a package

* Use pip while installing CJIO dependency for ifccityjson

* revert removal of brick module

* Changes from pull request review

* Use ifccityjson as CLI and as package for BlenderBIM
This commit is contained in:
Laurens Oostwegel
2021-11-08 22:51:30 +01:00
committed by GitHub
parent de7c54b771
commit ff6db5f24d
11 changed files with 185 additions and 19 deletions
+23
View File
@@ -0,0 +1,23 @@
# ifccityjson - Python CityJSON to IFC converter
# Copyright (C) 2021 Laurens J.N. Oostwegel <l.oostwegel@gmail.com>
#
# This file is part of ifccityjson.
#
# ifccityjson is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ifccityjson is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ifccityjson. If not, see <http://www.gnu.org/licenses/>.
from .cityjson2ifc import *
# Export version number
__version__ = "0.0.1"
+20
View File
@@ -0,0 +1,20 @@
# ifccityjson - Python CityJSON to IFC converter
# Copyright (C) 2021 Laurens J.N. Oostwegel <l.oostwegel@gmail.com>
#
# This file is part of ifccityjson.
#
# ifccityjson is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ifccityjson is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ifccityjson. If not, see <http://www.gnu.org/licenses/>.
from .cityjson2ifc import *
@@ -15,14 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with ifccityjson. If not, see <http://www.gnu.org/licenses/>.
import os
import copy
import os
import ifcopenshell
import ifcopenshell.api
from geometry import GeometryIO
from datetime import datetime
from .geometry import GeometryIO
JSON_TO_IFC = {
"Building": ["IfcBuilding"],
@@ -145,8 +144,8 @@ class Cityjson2ifc:
def create_representation_sub_contexts(self):
self.IFC_representation_sub_contexts = {}
for lod in self.city_model.j["metadata"]["presentLoDs"]:
self.IFC_representation_sub_contexts[str(lod)] = self.create_representation_sub_context(lod)
# for lod in self.city_model.j["metadata"]["presentLoDs"]:
# self.IFC_representation_sub_contexts[str(lod)] = self.create_representation_sub_context(lod)
def create_representation_sub_context(self, lod):
# TODO in ifcopenshell.api.context.add_context add support for UserDefinedTargetView
@@ -29,7 +29,7 @@ class GeometryIO:
def build_vertices(self, IFC_model, vertices):
for vertex in vertices:
self.build_vertex(self, IFC_model, vertex)
self.build_vertex(IFC_model, vertex)
def build_vertex(self, IFC_model, vertex):
if self.scale:
@@ -158,12 +158,11 @@ class GeometryIO:
if len(face) == 1:
return IFC_model.create_entity("IfcFace", Bounds=[outerbound])
return IFC_model.create_entity("IfcFace", [outerbound])
# interior face BUGS
# innerbounds = []
# for interior_face in face[1:]:
# for vertex in interior_face:
# vertices.append(self.get_vertex(IFC_model, vertex))
# polyloop = IFC_model.create_entity("IfcPolyLoop", Polygon=vertices)
# innerbounds.append(IFC_model.create_entity("IfcFaceBound", Bound=polyloop, Orientation=False))
# return IFC_model.create_entity("IfcFace", Bounds=[outerbound] + innerbounds)
innerbounds = []
for interior_face in face[1:]:
vertices = []
for vertex in interior_face:
vertices.append(self.get_vertex(IFC_model, vertex))
polyloop = IFC_model.create_entity("IfcPolyLoop", Polygon=vertices)
innerbounds.append(IFC_model.create_entity("IfcFaceBound", Bound=polyloop, Orientation=False))
return IFC_model.create_entity("IfcFace", Bounds=[outerbound] + innerbounds)
+6 -4
View File
@@ -1,4 +1,3 @@
# ifccityjson - Python CityJSON to IFC converter
# Copyright (C) 2021 Laurens J.N. Oostwegel <l.oostwegel@gmail.com>
#
@@ -16,12 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with ifccityjson. If not, see <http://www.gnu.org/licenses/>.
import argparse
from cjio import cityjson
from cityjson2ifc import Cityjson2ifc
from cityjson2ifc.cityjson2ifc import Cityjson2ifc
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
def cmdline():
# Example:
# python ifccityjson.py -i example/3DBAG_example.json -o example/output.ifc -n identificatie
# python ifccityjson.py -i example/geometries.json -o example/geometry_output.ifc
@@ -50,3 +49,6 @@ if __name__ == '__main__':
converter = Cityjson2ifc()
converter.configuration(**data)
converter.convert(city_model)
if __name__ == '__main__':
cmdline()