mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
tool.PsetTemplate
This commit is contained in:
@@ -25,34 +25,6 @@ import bonsai.bim.schema
|
||||
import bonsai.bim.handler
|
||||
import bonsai.tool as tool
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
from typing import final
|
||||
|
||||
|
||||
class PsetTemplateOperator:
|
||||
"""`tool.Ifc.Operator` but for pset template file."""
|
||||
|
||||
@final
|
||||
def execute(self, context):
|
||||
IfcStore.begin_transaction(self)
|
||||
template_file = IfcStore.pset_template_file
|
||||
assert template_file
|
||||
self.template_file = template_file
|
||||
template_file.begin_transaction()
|
||||
result = self._execute(context)
|
||||
template_file.end_transaction()
|
||||
IfcStore.add_transaction_operation(self)
|
||||
IfcStore.end_transaction(self)
|
||||
bonsai.bim.handler.refresh_ui_data()
|
||||
return {"FINISHED"}
|
||||
|
||||
def rollback(self, data):
|
||||
self.template_file.undo()
|
||||
|
||||
def commit(self, data):
|
||||
self.template_file.redo()
|
||||
|
||||
def _execute(self, context: bpy.types.Context) -> None:
|
||||
tool.Ifc.Operator._execute(self, context)
|
||||
|
||||
|
||||
class AddPsetTemplateFile(bpy.types.Operator):
|
||||
@@ -81,7 +53,7 @@ class AddPsetTemplateFile(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddPsetTemplate(bpy.types.Operator, PsetTemplateOperator):
|
||||
class AddPsetTemplate(bpy.types.Operator, tool.PsetTemplate.PsetTemplateOperator):
|
||||
bl_idname = "bim.add_pset_template"
|
||||
bl_label = "Add Pset Template"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
@@ -97,7 +69,7 @@ class AddPsetTemplate(bpy.types.Operator, PsetTemplateOperator):
|
||||
context.scene.BIMPsetTemplateProperties.pset_templates = str(template.id())
|
||||
|
||||
|
||||
class RemovePsetTemplate(bpy.types.Operator, PsetTemplateOperator):
|
||||
class RemovePsetTemplate(bpy.types.Operator, tool.PsetTemplate.PsetTemplateOperator):
|
||||
bl_idname = "bim.remove_pset_template"
|
||||
bl_label = "Remove Pset Template"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
@@ -206,7 +178,7 @@ class DisableEditingPropTemplate(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class EditPsetTemplate(bpy.types.Operator, PsetTemplateOperator):
|
||||
class EditPsetTemplate(bpy.types.Operator, tool.PsetTemplate.PsetTemplateOperator):
|
||||
bl_idname = "bim.edit_pset_template"
|
||||
bl_label = "Edit Pset Template"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
@@ -268,7 +240,7 @@ class RemovePsetTemplateFile(bpy.types.Operator):
|
||||
bonsai.bim.module.pset_template.prop.updatePsetTemplateFiles(self.props, context)
|
||||
|
||||
|
||||
class AddPropTemplate(bpy.types.Operator, PsetTemplateOperator):
|
||||
class AddPropTemplate(bpy.types.Operator, tool.PsetTemplate.PsetTemplateOperator):
|
||||
bl_idname = "bim.add_prop_template"
|
||||
bl_label = "Add Prop Template"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
@@ -287,7 +259,7 @@ class AddPropTemplate(bpy.types.Operator, PsetTemplateOperator):
|
||||
bonsai.bim.schema.reload(tool.Ifc.get().schema)
|
||||
|
||||
|
||||
class RemovePropTemplate(bpy.types.Operator, PsetTemplateOperator):
|
||||
class RemovePropTemplate(bpy.types.Operator, tool.PsetTemplate.PsetTemplateOperator):
|
||||
bl_idname = "bim.remove_prop_template"
|
||||
bl_label = "Remove Prop Template"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
@@ -304,7 +276,7 @@ class RemovePropTemplate(bpy.types.Operator, PsetTemplateOperator):
|
||||
bonsai.bim.schema.reload(tool.Ifc.get().schema)
|
||||
|
||||
|
||||
class EditPropTemplate(bpy.types.Operator, PsetTemplateOperator):
|
||||
class EditPropTemplate(bpy.types.Operator, tool.PsetTemplate.PsetTemplateOperator):
|
||||
bl_idname = "bim.edit_prop_template"
|
||||
bl_label = "Edit Prop Template"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@@ -673,6 +673,11 @@ class Pset:
|
||||
def set_active_pset(cls, props, pset, has_template): pass
|
||||
|
||||
|
||||
@interface
|
||||
class PsetTemplate:
|
||||
pass
|
||||
|
||||
|
||||
@interface
|
||||
class Qto:
|
||||
def get_radius_of_selected_vertices(cls, obj): pass
|
||||
|
||||
@@ -48,6 +48,7 @@ from bonsai.tool.polyline import Polyline
|
||||
from bonsai.tool.project import Project
|
||||
from bonsai.tool.profile import Profile
|
||||
from bonsai.tool.pset import Pset
|
||||
from bonsai.tool.pset_template import PsetTemplate
|
||||
from bonsai.tool.qto import Qto
|
||||
from bonsai.tool.raycast import Raycast
|
||||
from bonsai.tool.resource import Resource
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# Bonsai - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of Bonsai.
|
||||
#
|
||||
# Bonsai 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.
|
||||
#
|
||||
# Bonsai 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 Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.pset_template
|
||||
import ifcopenshell.util.attribute
|
||||
import ifcopenshell.util.element
|
||||
import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
from typing import Union, Literal, Any, final
|
||||
from typing_extensions import assert_never
|
||||
from bonsai.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class PsetTemplate(bonsai.core.tool.PsetTemplate):
|
||||
class PsetTemplateOperator:
|
||||
"""`tool.Ifc.Operator` but for pset template file."""
|
||||
|
||||
@final
|
||||
def execute(self, context):
|
||||
IfcStore.begin_transaction(self)
|
||||
template_file = IfcStore.pset_template_file
|
||||
assert template_file
|
||||
self.template_file = template_file
|
||||
template_file.begin_transaction()
|
||||
result = self._execute(context)
|
||||
template_file.end_transaction()
|
||||
IfcStore.add_transaction_operation(self)
|
||||
IfcStore.end_transaction(self)
|
||||
bonsai.bim.handler.refresh_ui_data()
|
||||
return {"FINISHED"}
|
||||
|
||||
def rollback(self, data):
|
||||
self.template_file.undo()
|
||||
|
||||
def commit(self, data):
|
||||
self.template_file.redo()
|
||||
|
||||
def _execute(self, context: bpy.types.Context) -> None:
|
||||
tool.Ifc.Operator._execute(self, context)
|
||||
Reference in New Issue
Block a user