mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 03:37:21 +00:00
Use new get_predefined_type_doc function #1982
This commit is contained in:
@@ -25,7 +25,7 @@ import ifcopenshell.util.element
|
|||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from blenderbim.bim.module.model.root import ConstrTypeEntityNotFound
|
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():
|
def refresh():
|
||||||
@@ -72,9 +72,12 @@ class AuthoringData:
|
|||||||
declaration = tool.Ifc().schema().declaration_by_name(cls.props.type_class)
|
declaration = tool.Ifc().schema().declaration_by_name(cls.props.type_class)
|
||||||
for attribute in declaration.attributes():
|
for attribute in declaration.attributes():
|
||||||
if attribute.name() == "PredefinedType":
|
if attribute.name() == "PredefinedType":
|
||||||
declared_type = attribute.type_of_attribute().declared_type()
|
results.extend(
|
||||||
descriptions = get_predefined_type_descriptions(declared_type.name())
|
[
|
||||||
results.extend([(e, e, descriptions.get(e, "")) for e in declared_type.enumeration_items()])
|
(e, e, get_predefined_type_description(cls.props.type_class, e))
|
||||||
|
for e in attribute.type_of_attribute().declared_type().enumeration_items()
|
||||||
|
]
|
||||||
|
)
|
||||||
break
|
break
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import bpy
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
from blenderbim.bim.ifc import IfcStore
|
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():
|
def refresh():
|
||||||
@@ -77,7 +77,6 @@ class IfcClassData:
|
|||||||
names = [d.name() for d in declarations]
|
names = [d.name() for d in declarations]
|
||||||
if ifc_product == "IfcElementType":
|
if ifc_product == "IfcElementType":
|
||||||
names.extend(("IfcDoorStyle", "IfcWindowStyle"))
|
names.extend(("IfcDoorStyle", "IfcWindowStyle"))
|
||||||
|
|
||||||
return [(c, c, get_ifc_entity_description(c)) for c in sorted(names)]
|
return [(c, c, get_ifc_entity_description(c)) for c in sorted(names)]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -87,9 +86,12 @@ class IfcClassData:
|
|||||||
declaration = tool.Ifc.schema().declaration_by_name(ifc_class)
|
declaration = tool.Ifc.schema().declaration_by_name(ifc_class)
|
||||||
for attribute in declaration.attributes():
|
for attribute in declaration.attributes():
|
||||||
if attribute.name() == "PredefinedType":
|
if attribute.name() == "PredefinedType":
|
||||||
declared_type = attribute.type_of_attribute().declared_type()
|
types_enum.extend(
|
||||||
descriptions = get_predefined_type_descriptions(declared_type.name())
|
[
|
||||||
types_enum.extend([(e, e, descriptions.get(e, "")) for e in declared_type.enumeration_items()])
|
(e, e, get_predefined_type_description(ifc_class, e))
|
||||||
|
for e in attribute.type_of_attribute().declared_type().enumeration_items()
|
||||||
|
]
|
||||||
|
)
|
||||||
break
|
break
|
||||||
return types_enum
|
return types_enum
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,13 @@ import json
|
|||||||
import importlib
|
import importlib
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.pset
|
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.handler
|
||||||
import blenderbim.bim.schema
|
import blenderbim.bim.schema
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
@@ -43,11 +49,6 @@ from bpy.props import (
|
|||||||
|
|
||||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
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 = []
|
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 ""
|
return docs.get("spec_url", "") if docs is not None else ""
|
||||||
|
|
||||||
|
|
||||||
def get_predefined_type_descriptions(ifc_class_enum):
|
def get_predefined_type_description(entity, predefined_type):
|
||||||
with open(DESCRIPTION_FILES["PredefinedType"], "r") as fi:
|
schema = tool.Ifc.get_schema()
|
||||||
docs = json.load(fi)
|
if schema is not None:
|
||||||
return docs.get(ifc_class_enum, None) or {}
|
return get_predefined_type_doc(schema, entity, predefined_type)
|
||||||
|
|
||||||
|
|
||||||
def getAttributeEnumValues(prop, context):
|
def getAttributeEnumValues(prop, context):
|
||||||
|
|||||||
Reference in New Issue
Block a user