From cbf7b0a77a612ac307f2487a2be9f9b6d8393305 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 9 Nov 2021 20:46:46 +1100 Subject: [PATCH] Minor clean up for CityJSON PR. --- src/blenderbim/Makefile | 1 + src/blenderbim/blenderbim/bim/export_ifc.py | 2 +- .../blenderbim/bim/module/gis/__init__.py | 22 +++++++++++- .../blenderbim/bim/module/gis/operator.py | 23 ++++++++++-- .../blenderbim/bim/module/gis/prop.py | 36 ++++++++++++++----- .../blenderbim/bim/module/gis/ui.py | 21 ++++++++++- 6 files changed, 92 insertions(+), 13 deletions(-) diff --git a/src/blenderbim/Makefile b/src/blenderbim/Makefile index d87c9a49b8..97f9b8b44f 100644 --- a/src/blenderbim/Makefile +++ b/src/blenderbim/Makefile @@ -262,6 +262,7 @@ endif cd dist/working && python -m venv env cd dist/working && mkdir 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/ rm -rf dist/working diff --git a/src/blenderbim/blenderbim/bim/export_ifc.py b/src/blenderbim/blenderbim/bim/export_ifc.py index 414b228203..5724be53b7 100644 --- a/src/blenderbim/blenderbim/bim/export_ifc.py +++ b/src/blenderbim/blenderbim/bim/export_ifc.py @@ -132,7 +132,7 @@ class IfcExporter: def sync_object_placement(self, obj): blender_matrix = np.array(obj.matrix_world) 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) return element if element.is_a("IfcGridAxis"): diff --git a/src/blenderbim/blenderbim/bim/module/gis/__init__.py b/src/blenderbim/blenderbim/bim/module/gis/__init__.py index e894239cd4..98f80ecda8 100644 --- a/src/blenderbim/blenderbim/bim/module/gis/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/gis/__init__.py @@ -1,3 +1,21 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2021 Dion Moult +# +# 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 . + import bpy from . import prop from . import operator @@ -10,8 +28,10 @@ classes = ( ui.BIM_PT_cityjson_converter, ) + def register(): bpy.types.Scene.ifccityjson_properties = bpy.props.PointerProperty(type=prop.BIMCityJsonProperties) + def unregister(): - del bpy.types.Scene.ifccityjson_properties \ No newline at end of file + del bpy.types.Scene.ifccityjson_properties diff --git a/src/blenderbim/blenderbim/bim/module/gis/operator.py b/src/blenderbim/blenderbim/bim/module/gis/operator.py index 7cbc2eb1bf..09c71dc9d1 100644 --- a/src/blenderbim/blenderbim/bim/module/gis/operator.py +++ b/src/blenderbim/blenderbim/bim/module/gis/operator.py @@ -1,8 +1,27 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2021 Dion Moult +# +# 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 . + import bpy from bpy.types import Operator from cjio import cityjson from ifccityjson.cityjson2ifc.cityjson2ifc import Cityjson2ifc + class BIM_OT_cityjson2ifc(Operator): bl_idname = "bim.convert_cityjson2ifc" bl_label = "Convert CityJSON to IFC" @@ -24,7 +43,7 @@ class BIM_OT_cityjson2ifc(Operator): converter.convert(city_model) if props.load_after_convert: bpy.ops.bim.load_project(filepath=props.output) - return {'FINISHED'} + return {"FINISHED"} class BIM_OT_find_cityjson_lod(Operator): @@ -44,4 +63,4 @@ class BIM_OT_find_cityjson_lod(Operator): props.lods.add() props.lods[-1].name = lod props.is_lod_found = True - return {'FINISHED'} + return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/gis/prop.py b/src/blenderbim/blenderbim/bim/module/gis/prop.py index f9671dfa65..e5fc1640d1 100644 --- a/src/blenderbim/blenderbim/bim/module/gis/prop.py +++ b/src/blenderbim/blenderbim/bim/module/gis/prop.py @@ -1,16 +1,36 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2021 Dion Moult +# +# 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 . + from bpy.types import PropertyGroup from bpy.props import StringProperty, BoolProperty, EnumProperty, CollectionProperty from blenderbim.bim.prop import StrProperty + class BIMCityJsonProperties(PropertyGroup): def get_lods(self, context): 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') - output: StringProperty(name="ifc_output", default="", subtype='FILE_PATH') - name: StringProperty(name="identifier", default="") - split_lod: BoolProperty(name="split_lod", default=True) - lods: CollectionProperty(name="lods", type=StrProperty) - lod: EnumProperty(name="lod", description="", items=get_lods, options={'ANIMATABLE'}, default=None) - is_lod_found: BoolProperty(name="is_lod_found", default=False) - load_after_convert: BoolProperty(name="load_after_convert", default=True) + # TODO: instead of subtype it would be nice to have a helper operator that allows filtered file browsing + input: StringProperty(name="CityJSON Input", default="", subtype="FILE_PATH") + output: StringProperty(name="IFC Output", default="", subtype="FILE_PATH") + name: StringProperty(name="Identifier", default="") + split_lod: BoolProperty(name="Should Split LOD", default=True) + lods: CollectionProperty(name="LODs", type=StrProperty) + lod: EnumProperty(name="LOD", description="", items=get_lods, options={"ANIMATABLE"}, default=None) + is_lod_found: BoolProperty(name="Is LOD Found", default=False) + load_after_convert: BoolProperty(name="Load After Converting", default=True) diff --git a/src/blenderbim/blenderbim/bim/module/gis/ui.py b/src/blenderbim/blenderbim/bim/module/gis/ui.py index 3d099ee6db..cdf443f800 100644 --- a/src/blenderbim/blenderbim/bim/module/gis/ui.py +++ b/src/blenderbim/blenderbim/bim/module/gis/ui.py @@ -1,7 +1,26 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2021 Dion Moult +# +# 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 . + from bpy.types import Panel + class BIM_PT_cityjson_converter(Panel): - bl_label = "IFC CityJSON converter" + bl_label = "IFC CityJSON" bl_idname = "BIM_PT_ifccityjson" bl_options = {"DEFAULT_CLOSED"} bl_space_type = "PROPERTIES"