mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
Directly use predefined type doc function instead of wrapper
This commit is contained in:
@@ -23,12 +23,11 @@ import math
|
|||||||
import zipfile
|
import zipfile
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.attribute
|
import ifcopenshell.util.attribute
|
||||||
from ifcopenshell.util.doc import get_attribute_doc
|
from ifcopenshell.util.doc import get_attribute_doc, get_predefined_type_doc
|
||||||
from mathutils import geometry
|
from mathutils import geometry
|
||||||
from mathutils import Vector
|
from mathutils import Vector
|
||||||
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_predefined_type_description
|
|
||||||
|
|
||||||
|
|
||||||
def draw_attributes(props, layout, copy_operator=None):
|
def draw_attributes(props, layout, copy_operator=None):
|
||||||
@@ -116,10 +115,14 @@ def add_attribute_enum_items_descriptions(attribute_blender, enum_items):
|
|||||||
attribute_blender.enum_descriptions.clear()
|
attribute_blender.enum_descriptions.clear()
|
||||||
if isinstance(enum_items, dict):
|
if isinstance(enum_items, dict):
|
||||||
enum_items = enum_items.keys()
|
enum_items = enum_items.keys()
|
||||||
|
version = tool.Ifc.get_schema()
|
||||||
for enum_item in enum_items:
|
for enum_item in enum_items:
|
||||||
new_enum_description = attribute_blender.enum_descriptions.add()
|
new_enum_description = attribute_blender.enum_descriptions.add()
|
||||||
# TODO this only supports predefined type enums. Add support for other types of enums ?
|
try:
|
||||||
new_enum_description.name = get_predefined_type_description(attribute_blender.ifc_class, enum_item) or ""
|
description = get_predefined_type_doc(version, attribute_blender.ifc_class, enum_item)
|
||||||
|
except KeyError: # TODO this only supports predefined type enums. Add support for other types of enums ?
|
||||||
|
description = ""
|
||||||
|
new_enum_description.name = description
|
||||||
|
|
||||||
|
|
||||||
def add_attribute_description(attribute_blender):
|
def add_attribute_description(attribute_blender):
|
||||||
|
|||||||
@@ -22,12 +22,10 @@ import json
|
|||||||
import functools
|
import functools
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
from ifcopenshell.util.doc import get_entity_doc
|
from ifcopenshell.util.doc import get_entity_doc, get_predefined_type_doc
|
||||||
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_predefined_type_description
|
|
||||||
|
|
||||||
|
|
||||||
def refresh():
|
def refresh():
|
||||||
AuthoringData.is_loaded = False
|
AuthoringData.is_loaded = False
|
||||||
@@ -72,11 +70,12 @@ class AuthoringData:
|
|||||||
def type_predefined_type(cls):
|
def type_predefined_type(cls):
|
||||||
results = []
|
results = []
|
||||||
declaration = tool.Ifc().schema().declaration_by_name(cls.props.type_class)
|
declaration = tool.Ifc().schema().declaration_by_name(cls.props.type_class)
|
||||||
|
version = tool.Ifc.get_schema()
|
||||||
for attribute in declaration.attributes():
|
for attribute in declaration.attributes():
|
||||||
if attribute.name() == "PredefinedType":
|
if attribute.name() == "PredefinedType":
|
||||||
results.extend(
|
results.extend(
|
||||||
[
|
[
|
||||||
(e, e, get_predefined_type_description(cls.props.type_class, e))
|
(e, e, get_predefined_type_doc(version, cls.props.type_class, e))
|
||||||
for e in attribute.type_of_attribute().declared_type().enumeration_items()
|
for e in attribute.type_of_attribute().declared_type().enumeration_items()
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,10 +19,9 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
from ifcopenshell.util.doc import get_entity_doc
|
from ifcopenshell.util.doc import get_entity_doc, get_predefined_type_doc
|
||||||
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_predefined_type_description
|
|
||||||
|
|
||||||
|
|
||||||
def refresh():
|
def refresh():
|
||||||
@@ -87,11 +86,12 @@ class IfcClassData:
|
|||||||
types_enum = []
|
types_enum = []
|
||||||
ifc_class = bpy.context.scene.BIMRootProperties.ifc_class
|
ifc_class = bpy.context.scene.BIMRootProperties.ifc_class
|
||||||
declaration = tool.Ifc.schema().declaration_by_name(ifc_class)
|
declaration = tool.Ifc.schema().declaration_by_name(ifc_class)
|
||||||
|
version = tool.Ifc.get_schema()
|
||||||
for attribute in declaration.attributes():
|
for attribute in declaration.attributes():
|
||||||
if attribute.name() == "PredefinedType":
|
if attribute.name() == "PredefinedType":
|
||||||
types_enum.extend(
|
types_enum.extend(
|
||||||
[
|
[
|
||||||
(e, e, get_predefined_type_description(ifc_class, e))
|
(e, e, get_predefined_type_doc(version, ifc_class, e))
|
||||||
for e in attribute.type_of_attribute().declared_type().enumeration_items()
|
for e in attribute.type_of_attribute().declared_type().enumeration_items()
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -106,15 +106,6 @@ def cache_string(s):
|
|||||||
cache_string.data = {}
|
cache_string.data = {}
|
||||||
|
|
||||||
|
|
||||||
def get_predefined_type_description(entity, predefined_type):
|
|
||||||
schema = tool.Ifc.get_schema()
|
|
||||||
if schema is not None:
|
|
||||||
try:
|
|
||||||
return get_predefined_type_doc(schema, entity, predefined_type)
|
|
||||||
except KeyError: # This entity doesn't have any predefined types
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
def get_attribute_enum_values(prop, context):
|
def get_attribute_enum_values(prop, context):
|
||||||
# Support weird buildingSMART dictionary mappings which behave like enums
|
# Support weird buildingSMART dictionary mappings which behave like enums
|
||||||
items = []
|
items = []
|
||||||
|
|||||||
Reference in New Issue
Block a user