Use new get_predefined_type_doc function #1982

This commit is contained in:
Gorgious56
2022-10-27 16:00:12 +02:00
parent 4533b74d65
commit 17a872a8d8
3 changed files with 25 additions and 19 deletions
@@ -25,7 +25,7 @@ import ifcopenshell.util.element
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.model.root import ConstrTypeEntityNotFound
from blenderbim.bim.prop import get_ifc_entity_description, get_predefined_type_descriptions
from blenderbim.bim.prop import get_ifc_entity_description, get_predefined_type_description
def refresh():
@@ -72,9 +72,12 @@ class AuthoringData:
declaration = tool.Ifc().schema().declaration_by_name(cls.props.type_class)
for attribute in declaration.attributes():
if attribute.name() == "PredefinedType":
declared_type = attribute.type_of_attribute().declared_type()
descriptions = get_predefined_type_descriptions(declared_type.name())
results.extend([(e, e, descriptions.get(e, "")) for e in declared_type.enumeration_items()])
results.extend(
[
(e, e, get_predefined_type_description(cls.props.type_class, e))
for e in attribute.type_of_attribute().declared_type().enumeration_items()
]
)
break
return results
@@ -21,7 +21,7 @@ import bpy
import ifcopenshell.util.element
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.prop import get_ifc_entity_description, get_predefined_type_descriptions
from blenderbim.bim.prop import get_ifc_entity_description, get_predefined_type_description
def refresh():
@@ -77,7 +77,6 @@ class IfcClassData:
names = [d.name() for d in declarations]
if ifc_product == "IfcElementType":
names.extend(("IfcDoorStyle", "IfcWindowStyle"))
return [(c, c, get_ifc_entity_description(c)) for c in sorted(names)]
@classmethod
@@ -87,9 +86,12 @@ class IfcClassData:
declaration = tool.Ifc.schema().declaration_by_name(ifc_class)
for attribute in declaration.attributes():
if attribute.name() == "PredefinedType":
declared_type = attribute.type_of_attribute().declared_type()
descriptions = get_predefined_type_descriptions(declared_type.name())
types_enum.extend([(e, e, descriptions.get(e, "")) for e in declared_type.enumeration_items()])
types_enum.extend(
[
(e, e, get_predefined_type_description(ifc_class, e))
for e in attribute.type_of_attribute().declared_type().enumeration_items()
]
)
break
return types_enum
+11 -10
View File
@@ -23,7 +23,13 @@ import json
import importlib
import ifcopenshell
import ifcopenshell.util.pset
from ifcopenshell.util.doc import get_entity_doc, get_attribute_doc, get_property_set_doc, get_property_doc
from ifcopenshell.util.doc import (
get_entity_doc,
get_attribute_doc,
get_property_set_doc,
get_property_doc,
get_predefined_type_doc,
)
import blenderbim.bim.handler
import blenderbim.bim.schema
from blenderbim.bim.ifc import IfcStore
@@ -43,11 +49,6 @@ from bpy.props import (
cwd = os.path.dirname(os.path.realpath(__file__))
BASE_MODULE_PATH = Path(__file__).parent
DESCRIPTION_FILES = {
"PredefinedType": BASE_MODULE_PATH / "schema" / "enum_descriptions.json",
}
materialpsetnames_enum = []
@@ -121,10 +122,10 @@ def get_ifc_entity_doc_url(ifc_entity):
return docs.get("spec_url", "") if docs is not None else ""
def get_predefined_type_descriptions(ifc_class_enum):
with open(DESCRIPTION_FILES["PredefinedType"], "r") as fi:
docs = json.load(fi)
return docs.get(ifc_class_enum, None) or {}
def get_predefined_type_description(entity, predefined_type):
schema = tool.Ifc.get_schema()
if schema is not None:
return get_predefined_type_doc(schema, entity, predefined_type)
def getAttributeEnumValues(prop, context):