Minor clean up for CityJSON PR.

This commit is contained in:
Dion Moult
2021-11-09 20:46:46 +11:00
parent 91f2f9438f
commit cbf7b0a77a
6 changed files with 92 additions and 13 deletions
+1
View File
@@ -262,6 +262,7 @@ endif
cd dist/working && python -m venv env cd dist/working && python -m venv env
cd dist/working && mkdir site-packages cd dist/working && mkdir site-packages
cd dist/working && . env/bin/activate && pip install cjio --target=./site-packages cd dist/working && . env/bin/activate && pip install cjio --target=./site-packages
cd dist/working/site-packages/ && rm -r *dist-info*
cp -r dist/working/site-packages/* dist/blenderbim/libs/site/packages/ cp -r dist/working/site-packages/* dist/blenderbim/libs/site/packages/
rm -rf dist/working rm -rf dist/working
+1 -1
View File
@@ -132,7 +132,7 @@ class IfcExporter:
def sync_object_placement(self, obj): def sync_object_placement(self, obj):
blender_matrix = np.array(obj.matrix_world) blender_matrix = np.array(obj.matrix_world)
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id) element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
if list(obj.scale) != [1., 1., 1.]: if list(obj.scale) != [1.0, 1.0, 1.0]:
bpy.ops.bim.update_representation(obj=obj.name) bpy.ops.bim.update_representation(obj=obj.name)
return element return element
if element.is_a("IfcGridAxis"): if element.is_a("IfcGridAxis"):
@@ -1,3 +1,21 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
#
# This file is part of BlenderBIM Add-on.
#
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BlenderBIM Add-on 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import bpy import bpy
from . import prop from . import prop
from . import operator from . import operator
@@ -10,8 +28,10 @@ classes = (
ui.BIM_PT_cityjson_converter, ui.BIM_PT_cityjson_converter,
) )
def register(): def register():
bpy.types.Scene.ifccityjson_properties = bpy.props.PointerProperty(type=prop.BIMCityJsonProperties) bpy.types.Scene.ifccityjson_properties = bpy.props.PointerProperty(type=prop.BIMCityJsonProperties)
def unregister(): def unregister():
del bpy.types.Scene.ifccityjson_properties del bpy.types.Scene.ifccityjson_properties
@@ -1,8 +1,27 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
#
# This file is part of BlenderBIM Add-on.
#
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BlenderBIM Add-on 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import bpy import bpy
from bpy.types import Operator from bpy.types import Operator
from cjio import cityjson from cjio import cityjson
from ifccityjson.cityjson2ifc.cityjson2ifc import Cityjson2ifc from ifccityjson.cityjson2ifc.cityjson2ifc import Cityjson2ifc
class BIM_OT_cityjson2ifc(Operator): class BIM_OT_cityjson2ifc(Operator):
bl_idname = "bim.convert_cityjson2ifc" bl_idname = "bim.convert_cityjson2ifc"
bl_label = "Convert CityJSON to IFC" bl_label = "Convert CityJSON to IFC"
@@ -24,7 +43,7 @@ class BIM_OT_cityjson2ifc(Operator):
converter.convert(city_model) converter.convert(city_model)
if props.load_after_convert: if props.load_after_convert:
bpy.ops.bim.load_project(filepath=props.output) bpy.ops.bim.load_project(filepath=props.output)
return {'FINISHED'} return {"FINISHED"}
class BIM_OT_find_cityjson_lod(Operator): class BIM_OT_find_cityjson_lod(Operator):
@@ -44,4 +63,4 @@ class BIM_OT_find_cityjson_lod(Operator):
props.lods.add() props.lods.add()
props.lods[-1].name = lod props.lods[-1].name = lod
props.is_lod_found = True props.is_lod_found = True
return {'FINISHED'} return {"FINISHED"}
@@ -1,16 +1,36 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
#
# This file is part of BlenderBIM Add-on.
#
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BlenderBIM Add-on 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
from bpy.types import PropertyGroup from bpy.types import PropertyGroup
from bpy.props import StringProperty, BoolProperty, EnumProperty, CollectionProperty from bpy.props import StringProperty, BoolProperty, EnumProperty, CollectionProperty
from blenderbim.bim.prop import StrProperty from blenderbim.bim.prop import StrProperty
class BIMCityJsonProperties(PropertyGroup): class BIMCityJsonProperties(PropertyGroup):
def get_lods(self, context): def get_lods(self, context):
return [(item.name, "LOD" + item.name, "Level of Detail " + item.name) for item in self.lods] return [(item.name, "LOD" + item.name, "Level of Detail " + item.name) for item in self.lods]
input: StringProperty(name="cj_input", default="", subtype='FILE_PATH') # TODO: instead of subtype it would be nice to have a helper operator that allows filtered file browsing
output: StringProperty(name="ifc_output", default="", subtype='FILE_PATH') input: StringProperty(name="CityJSON Input", default="", subtype="FILE_PATH")
name: StringProperty(name="identifier", default="") output: StringProperty(name="IFC Output", default="", subtype="FILE_PATH")
split_lod: BoolProperty(name="split_lod", default=True) name: StringProperty(name="Identifier", default="")
lods: CollectionProperty(name="lods", type=StrProperty) split_lod: BoolProperty(name="Should Split LOD", default=True)
lod: EnumProperty(name="lod", description="", items=get_lods, options={'ANIMATABLE'}, default=None) lods: CollectionProperty(name="LODs", type=StrProperty)
is_lod_found: BoolProperty(name="is_lod_found", default=False) lod: EnumProperty(name="LOD", description="", items=get_lods, options={"ANIMATABLE"}, default=None)
load_after_convert: BoolProperty(name="load_after_convert", default=True) is_lod_found: BoolProperty(name="Is LOD Found", default=False)
load_after_convert: BoolProperty(name="Load After Converting", default=True)
+20 -1
View File
@@ -1,7 +1,26 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
#
# This file is part of BlenderBIM Add-on.
#
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BlenderBIM Add-on 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
from bpy.types import Panel from bpy.types import Panel
class BIM_PT_cityjson_converter(Panel): class BIM_PT_cityjson_converter(Panel):
bl_label = "IFC CityJSON converter" bl_label = "IFC CityJSON"
bl_idname = "BIM_PT_ifccityjson" bl_idname = "BIM_PT_ifccityjson"
bl_options = {"DEFAULT_CLOSED"} bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES" bl_space_type = "PROPERTIES"