2021-08-17 08:55:29 +10:00
|
|
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
|
|
|
|
# Copyright (C) 2020, 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/>.
|
|
|
|
|
|
2021-01-06 17:57:24 +11:00
|
|
|
import bpy
|
2021-10-07 18:51:50 +11:00
|
|
|
import blenderbim.bim.handler
|
|
|
|
|
import blenderbim.tool as tool
|
|
|
|
|
import blenderbim.core.style as core
|
2022-02-09 11:34:59 +11:00
|
|
|
import ifcopenshell.util.representation
|
2021-01-06 17:57:24 +11:00
|
|
|
from blenderbim.bim.ifc import IfcStore
|
|
|
|
|
|
|
|
|
|
|
2022-05-08 18:03:18 +10:00
|
|
|
class UpdateStyleColours(bpy.types.Operator, tool.Ifc.Operator):
|
2021-07-10 12:34:25 +10:00
|
|
|
bl_idname = "bim.update_style_colours"
|
|
|
|
|
bl_label = "Update Style Colours"
|
2021-07-04 20:28:21 +10:00
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
|
|
|
|
|
|
|
|
|
def _execute(self, context):
|
2021-10-07 18:51:50 +11:00
|
|
|
core.update_style_colours(tool.Ifc, tool.Style, obj=context.active_object.active_material)
|
2021-01-06 17:57:24 +11:00
|
|
|
|
|
|
|
|
|
2022-05-08 18:03:18 +10:00
|
|
|
class UpdateStyleTextures(bpy.types.Operator, tool.Ifc.Operator):
|
2022-02-09 11:34:59 +11:00
|
|
|
bl_idname = "bim.update_style_textures"
|
|
|
|
|
bl_label = "Update Style Textures"
|
|
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
|
|
|
|
|
|
|
|
|
def _execute(self, context):
|
|
|
|
|
representation = ifcopenshell.util.representation.get_representation(
|
|
|
|
|
tool.Ifc.get_entity(context.active_object), "Model", "Body", "MODEL_VIEW"
|
|
|
|
|
)
|
|
|
|
|
if representation:
|
|
|
|
|
core.update_style_textures(
|
|
|
|
|
tool.Ifc, tool.Style, obj=context.active_object.active_material, representation=representation
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2022-05-08 18:03:18 +10:00
|
|
|
class RemoveStyle(bpy.types.Operator, tool.Ifc.Operator):
|
2021-07-10 11:43:01 +10:00
|
|
|
bl_idname = "bim.remove_style"
|
|
|
|
|
bl_label = "Remove Style"
|
|
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
2022-03-26 21:17:52 +11:00
|
|
|
style: bpy.props.IntProperty()
|
2021-07-10 11:43:01 +10:00
|
|
|
|
|
|
|
|
def _execute(self, context):
|
2022-03-26 21:17:52 +11:00
|
|
|
core.remove_style(tool.Ifc, tool.Material, tool.Style, style=tool.Ifc.get().by_id(self.style))
|
2021-07-10 11:43:01 +10:00
|
|
|
|
|
|
|
|
|
2022-05-08 18:03:18 +10:00
|
|
|
class AddStyle(bpy.types.Operator, tool.Ifc.Operator):
|
2021-01-06 17:57:24 +11:00
|
|
|
bl_idname = "bim.add_style"
|
|
|
|
|
bl_label = "Add Style"
|
2021-07-03 10:03:22 +10:00
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
|
|
|
|
|
|
|
|
|
def _execute(self, context):
|
2021-10-07 18:51:50 +11:00
|
|
|
core.add_style(tool.Ifc, tool.Style, obj=context.active_object.active_material)
|
2021-03-09 12:50:50 +11:00
|
|
|
|
|
|
|
|
|
2022-05-08 18:03:18 +10:00
|
|
|
class UnlinkStyle(bpy.types.Operator, tool.Ifc.Operator):
|
2021-03-09 12:50:50 +11:00
|
|
|
bl_idname = "bim.unlink_style"
|
|
|
|
|
bl_label = "Unlink Style"
|
2021-07-04 20:28:21 +10:00
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
2021-03-09 12:50:50 +11:00
|
|
|
|
2021-10-07 18:51:50 +11:00
|
|
|
def _execute(self, context):
|
2021-11-11 14:18:44 +11:00
|
|
|
core.unlink_style(tool.Ifc, tool.Style, obj=context.active_object.active_material)
|
2021-07-10 12:34:25 +10:00
|
|
|
|
|
|
|
|
|
2022-05-08 18:03:18 +10:00
|
|
|
class EnableEditingStyle(bpy.types.Operator, tool.Ifc.Operator):
|
2021-07-10 12:34:25 +10:00
|
|
|
bl_idname = "bim.enable_editing_style"
|
|
|
|
|
bl_label = "Enable Editing Style"
|
|
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
|
|
|
|
|
2021-10-07 18:51:50 +11:00
|
|
|
def _execute(self, context):
|
|
|
|
|
core.enable_editing_style(tool.Style, obj=context.active_object.active_material)
|
2021-07-10 12:34:25 +10:00
|
|
|
|
|
|
|
|
|
2022-05-08 18:03:18 +10:00
|
|
|
class DisableEditingStyle(bpy.types.Operator, tool.Ifc.Operator):
|
2021-07-10 12:34:25 +10:00
|
|
|
bl_idname = "bim.disable_editing_style"
|
|
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
|
|
|
|
bl_label = "Disable Editing Style"
|
|
|
|
|
|
2021-10-07 18:51:50 +11:00
|
|
|
def _execute(self, context):
|
|
|
|
|
core.disable_editing_style(tool.Style, obj=context.active_object.active_material)
|
2021-07-10 12:34:25 +10:00
|
|
|
|
|
|
|
|
|
2022-05-08 18:03:18 +10:00
|
|
|
class EditStyle(bpy.types.Operator, tool.Ifc.Operator):
|
2021-07-10 12:34:25 +10:00
|
|
|
bl_idname = "bim.edit_style"
|
|
|
|
|
bl_label = "Edit Style"
|
|
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
|
|
|
|
|
|
|
|
|
def _execute(self, context):
|
2021-10-07 18:51:50 +11:00
|
|
|
core.edit_style(tool.Ifc, tool.Style, obj=context.active_object.active_material)
|
2022-03-26 18:15:30 +11:00
|
|
|
|
|
|
|
|
|
2022-05-08 18:03:18 +10:00
|
|
|
class DisableEditingStyles(bpy.types.Operator, tool.Ifc.Operator):
|
2022-03-26 18:15:30 +11:00
|
|
|
bl_idname = "bim.disable_editing_styles"
|
|
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
|
|
|
|
bl_label = "Disable Editing Styles"
|
|
|
|
|
|
|
|
|
|
def _execute(self, context):
|
|
|
|
|
core.disable_editing_styles(tool.Style)
|
|
|
|
|
|
|
|
|
|
|
2022-05-08 18:03:18 +10:00
|
|
|
class LoadStyles(bpy.types.Operator, tool.Ifc.Operator):
|
2022-03-26 18:15:30 +11:00
|
|
|
bl_idname = "bim.load_styles"
|
|
|
|
|
bl_label = "Load Styles"
|
|
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
|
|
|
|
style_type: bpy.props.StringProperty()
|
|
|
|
|
|
|
|
|
|
def _execute(self, context):
|
|
|
|
|
core.load_styles(tool.Style, style_type=self.style_type)
|
2022-05-08 18:03:18 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class SelectByStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|
|
|
|
bl_idname = "bim.select_by_style"
|
|
|
|
|
bl_label = "Select By Material"
|
|
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
|
|
|
|
style: bpy.props.IntProperty()
|
|
|
|
|
|
|
|
|
|
def _execute(self, context):
|
|
|
|
|
core.select_by_style(tool.Style, style=tool.Ifc.get().by_id(self.style))
|