mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Fix #4167. Bug where pset template module didn't allow creating qto template types.
This commit is contained in:
@@ -20,6 +20,7 @@ import os
|
||||
import bpy
|
||||
import pathlib
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.attribute
|
||||
import blenderbim.tool as tool
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
@@ -36,6 +37,7 @@ class PsetTemplatesData:
|
||||
def load(cls):
|
||||
cls.is_loaded = True
|
||||
cls.data["primary_measure_type"] = cls.primary_measure_type()
|
||||
cls.data["property_template_type"] = cls.property_template_type()
|
||||
cls.data["pset_template_files"] = cls.pset_template_files()
|
||||
cls.data["pset_templates"] = cls.pset_templates()
|
||||
cls.data["pset_template"] = cls.pset_template()
|
||||
@@ -43,13 +45,25 @@ class PsetTemplatesData:
|
||||
|
||||
@classmethod
|
||||
def primary_measure_type(cls):
|
||||
schema = tool.Ifc.schema()
|
||||
version = tool.Ifc.get_schema()
|
||||
ifc_file = IfcStore.pset_template_file
|
||||
if not ifc_file:
|
||||
return []
|
||||
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema)
|
||||
version = ifc_file.schema
|
||||
return [
|
||||
(t, t, ifcopenshell.util.doc.get_type_doc(version, t).get("description", ""))
|
||||
for t in sorted([d.name() for d in schema.declarations() if hasattr(d, "declared_type")])
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def property_template_type(cls):
|
||||
ifc_file = IfcStore.pset_template_file
|
||||
if not ifc_file:
|
||||
return []
|
||||
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema)
|
||||
attribute = schema.declaration_by_name("IfcSimplePropertyTemplate").attributes()[0]
|
||||
return [(i, i, "") for i in ifcopenshell.util.attribute.get_enum_items(attribute)]
|
||||
|
||||
@classmethod
|
||||
def pset_template_files(cls):
|
||||
results = []
|
||||
|
||||
@@ -307,7 +307,8 @@ class EditPropTemplate(bpy.types.Operator, Operator):
|
||||
bpy.ops.bim.disable_editing_prop_template()
|
||||
IfcStore.pset_template_file.write(IfcStore.pset_template_path)
|
||||
blenderbim.bim.handler.refresh_ui_data()
|
||||
blenderbim.bim.schema.reload(tool.Ifc.get().schema)
|
||||
if tool.Ifc.get():
|
||||
blenderbim.bim.schema.reload(tool.Ifc.get().schema)
|
||||
|
||||
# TODO -This will need to go into the
|
||||
# api code at some point - vulevukusej
|
||||
|
||||
@@ -42,6 +42,8 @@ def updatePsetTemplateFiles(self, context):
|
||||
PsetTemplatesData.data["pset_template_files"] = PsetTemplatesData.pset_template_files()
|
||||
PsetTemplatesData.data["pset_templates"] = PsetTemplatesData.pset_templates()
|
||||
PsetTemplatesData.data["prop_templates"] = PsetTemplatesData.prop_templates()
|
||||
PsetTemplatesData.data["primary_measure_type"] = PsetTemplatesData.primary_measure_type()
|
||||
PsetTemplatesData.data["property_template_type"] = PsetTemplatesData.property_template_type()
|
||||
|
||||
|
||||
def getPsetTemplateFiles(self, context):
|
||||
@@ -67,6 +69,12 @@ def get_primary_measure_type(self, context):
|
||||
return PsetTemplatesData.data["primary_measure_type"]
|
||||
|
||||
|
||||
def get_property_template_type(self, context):
|
||||
if not PsetTemplatesData.is_loaded:
|
||||
PsetTemplatesData.load()
|
||||
return PsetTemplatesData.data["property_template_type"]
|
||||
|
||||
|
||||
def get_template_type(self, context):
|
||||
return [
|
||||
(
|
||||
@@ -157,10 +165,7 @@ class PropTemplate(PropertyGroup):
|
||||
description=get_attribute_doc("IFC4", "IfcPropertyTemplate", "Description"),
|
||||
)
|
||||
primary_measure_type: EnumProperty(items=get_primary_measure_type, name="Primary Measure Type")
|
||||
template_type: EnumProperty(
|
||||
items=[("P_SINGLEVALUE", "P_SINGLEVALUE", ""), ("P_ENUMERATEDVALUE", "P_ENUMERATEDVALUE", "")],
|
||||
name="Template Type",
|
||||
)
|
||||
template_type: EnumProperty(items=get_property_template_type, name="Template Type")
|
||||
enum_values: CollectionProperty(type=EnumerationValues)
|
||||
|
||||
def get_value_name(self):
|
||||
|
||||
Reference in New Issue
Block a user