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-03 12:08:00 +11:00
|
|
|
import bpy
|
2021-09-30 08:46:02 +10:00
|
|
|
import blenderbim.tool as tool
|
|
|
|
|
import blenderbim.core.context as core
|
2021-09-30 12:08:07 +10:00
|
|
|
import blenderbim.bim.module.context.data
|
2021-01-03 19:09:01 +11:00
|
|
|
from blenderbim.bim.ifc import IfcStore
|
2021-03-25 10:48:31 +11:00
|
|
|
from ifcopenshell.api.context.data import Data
|
2021-01-03 12:08:00 +11:00
|
|
|
|
2021-01-03 19:09:01 +11:00
|
|
|
|
2021-09-30 12:08:07 +10:00
|
|
|
class Operator:
|
|
|
|
|
def execute(self, context):
|
|
|
|
|
IfcStore.execute_ifc_operator(self, context)
|
|
|
|
|
blenderbim.bim.module.context.data.ContextData.is_loaded = False
|
|
|
|
|
return {"FINISHED"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AddSubcontext(bpy.types.Operator, Operator):
|
2021-01-03 12:08:00 +11:00
|
|
|
bl_idname = "bim.add_subcontext"
|
|
|
|
|
bl_label = "Add Subcontext"
|
2021-07-04 19:45:34 +10:00
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
2021-01-05 21:15:52 +11:00
|
|
|
context: bpy.props.StringProperty()
|
|
|
|
|
subcontext: bpy.props.StringProperty()
|
|
|
|
|
target_view: bpy.props.StringProperty()
|
2021-01-03 12:08:00 +11:00
|
|
|
|
2021-07-04 19:45:34 +10:00
|
|
|
def _execute(self, context):
|
2021-09-30 12:08:07 +10:00
|
|
|
core.add_context(tool.Ifc, context=self.context, subcontext=self.subcontext, target_view=self.target_view)
|
2021-01-03 12:08:00 +11:00
|
|
|
|
|
|
|
|
|
2021-09-30 12:08:07 +10:00
|
|
|
class RemoveSubcontext(bpy.types.Operator, Operator):
|
2021-01-03 12:08:00 +11:00
|
|
|
bl_idname = "bim.remove_subcontext"
|
|
|
|
|
bl_label = "Remove Context"
|
2021-07-04 19:45:34 +10:00
|
|
|
bl_options = {"REGISTER", "UNDO"}
|
2021-09-30 12:08:07 +10:00
|
|
|
context: bpy.props.IntProperty()
|
2021-07-04 19:45:34 +10:00
|
|
|
|
|
|
|
|
def _execute(self, context):
|
2021-09-30 12:08:07 +10:00
|
|
|
core.remove_context(tool.Ifc, context=tool.Ifc.get().by_id(self.context))
|