mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
Enable pset template editing on adding a new one #6019
This commit is contained in:
@@ -50,6 +50,7 @@ class AddPsetTemplateFile(bpy.types.Operator):
|
|||||||
bonsai.bim.handler.refresh_ui_data()
|
bonsai.bim.handler.refresh_ui_data()
|
||||||
bonsai.bim.schema.reload(tool.Ifc.get().schema)
|
bonsai.bim.schema.reload(tool.Ifc.get().schema)
|
||||||
context.scene.BIMPsetTemplateProperties.pset_template_files = filepath
|
context.scene.BIMPsetTemplateProperties.pset_template_files = filepath
|
||||||
|
tool.PsetTemplate.enable_editing_pset_template()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -96,16 +97,7 @@ class EnableEditingPsetTemplate(bpy.types.Operator):
|
|||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
props = context.scene.BIMPsetTemplateProperties
|
tool.PsetTemplate.enable_editing_pset_template()
|
||||||
props.active_pset_template_id = int(props.pset_templates)
|
|
||||||
template = IfcStore.pset_template_file.by_id(props.active_pset_template_id)
|
|
||||||
props.active_pset_template.global_id = template.GlobalId
|
|
||||||
props.active_pset_template.name = template.Name or ""
|
|
||||||
props.active_pset_template.description = template.Description or ""
|
|
||||||
props.active_pset_template.template_type = template.TemplateType
|
|
||||||
props.active_pset_template.applicable_entity = template.ApplicableEntity or ""
|
|
||||||
# Disable because of the intersecting enums in data.py.
|
|
||||||
props.active_prop_template_id = 0
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ from bpy.props import (
|
|||||||
FloatVectorProperty,
|
FloatVectorProperty,
|
||||||
CollectionProperty,
|
CollectionProperty,
|
||||||
)
|
)
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
|
||||||
def updatePsetTemplateFiles(self, context):
|
def updatePsetTemplateFiles(self, context):
|
||||||
@@ -147,6 +148,13 @@ class PsetTemplate(PropertyGroup):
|
|||||||
description=get_attribute_doc("IFC4", "IfcPropertySetTemplate", "ApplicableEntity"),
|
description=get_attribute_doc("IFC4", "IfcPropertySetTemplate", "ApplicableEntity"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
global_id: str
|
||||||
|
name: str
|
||||||
|
description: str
|
||||||
|
template_type: str
|
||||||
|
applicable_entity: str
|
||||||
|
|
||||||
|
|
||||||
class EnumerationValues(PropertyGroup):
|
class EnumerationValues(PropertyGroup):
|
||||||
string_value: StringProperty(name="Value")
|
string_value: StringProperty(name="Value")
|
||||||
@@ -206,3 +214,11 @@ class BIMPsetTemplateProperties(PropertyGroup):
|
|||||||
active_prop_template_id: IntProperty(name="Active Prop Template Id")
|
active_prop_template_id: IntProperty(name="Active Prop Template Id")
|
||||||
active_pset_template: PointerProperty(type=PsetTemplate)
|
active_pset_template: PointerProperty(type=PsetTemplate)
|
||||||
active_prop_template: PointerProperty(type=PropTemplate)
|
active_prop_template: PointerProperty(type=PropTemplate)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
pset_template_files: str
|
||||||
|
pset_templates: str
|
||||||
|
active_pset_template_id: int
|
||||||
|
active_prop_template_id: int
|
||||||
|
active_pset_template: PsetTemplate
|
||||||
|
active_prop_template: PropTemplate
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api.pset_template
|
import ifcopenshell.api.pset_template
|
||||||
@@ -24,9 +25,12 @@ import ifcopenshell.util.element
|
|||||||
import bonsai.core.tool
|
import bonsai.core.tool
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
from typing import Union, Literal, Any, final
|
from typing import Union, Literal, Any, final
|
||||||
from typing_extensions import assert_never
|
from typing_extensions import assert_never, TYPE_CHECKING
|
||||||
from bonsai.bim.ifc import IfcStore
|
from bonsai.bim.ifc import IfcStore
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from bonsai.bim.module.pset_template.prop import BIMPsetTemplateProperties
|
||||||
|
|
||||||
|
|
||||||
class PsetTemplate(bonsai.core.tool.PsetTemplate):
|
class PsetTemplate(bonsai.core.tool.PsetTemplate):
|
||||||
class PsetTemplateOperator:
|
class PsetTemplateOperator:
|
||||||
@@ -70,3 +74,24 @@ class PsetTemplate(bonsai.core.tool.PsetTemplate):
|
|||||||
primary_measure_type=property.NominalValue.is_a(),
|
primary_measure_type=property.NominalValue.is_a(),
|
||||||
)
|
)
|
||||||
return pset_template
|
return pset_template
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_pset_template_props(cls) -> BIMPsetTemplateProperties:
|
||||||
|
return bpy.context.scene.BIMPsetTemplateProperties
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def enable_editing_pset_template(cls) -> None:
|
||||||
|
props = cls.get_pset_template_props()
|
||||||
|
props.active_pset_template_id = int(props.pset_templates)
|
||||||
|
|
||||||
|
pset_template_file = IfcStore.pset_template_file
|
||||||
|
assert pset_template_file
|
||||||
|
template = pset_template_file.by_id(props.active_pset_template_id)
|
||||||
|
props.active_pset_template.global_id = template.GlobalId
|
||||||
|
props.active_pset_template.name = template.Name or ""
|
||||||
|
props.active_pset_template.description = template.Description or ""
|
||||||
|
props.active_pset_template.template_type = template.TemplateType
|
||||||
|
props.active_pset_template.applicable_entity = template.ApplicableEntity or ""
|
||||||
|
|
||||||
|
# Disable because of the intersecting enums in data.py.
|
||||||
|
props.active_prop_template_id = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user