mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
avoid even more invalid enum warnings...
warnings like `pyrna_enum_to_py: current value '17' matches no enum in 'BIMModelProperties', '', 'relating_type_id'`
This commit is contained in:
@@ -53,7 +53,7 @@ class AuthoringData:
|
|||||||
cls.data["ifc_element_type"] = cls.ifc_element_type
|
cls.data["ifc_element_type"] = cls.ifc_element_type
|
||||||
cls.data["ifc_classes"] = cls.ifc_classes()
|
cls.data["ifc_classes"] = cls.ifc_classes()
|
||||||
cls.data["relating_type_id"] = cls.relating_type_id() # only after .ifc_classes()
|
cls.data["relating_type_id"] = cls.relating_type_id() # only after .ifc_classes()
|
||||||
cls.data["predefined_type"] = cls.predefined_type()
|
cls.data["predefined_type"] = cls.predefined_type() # only after .relating_type_id()
|
||||||
cls.data["type_class"] = cls.type_class()
|
cls.data["type_class"] = cls.type_class()
|
||||||
|
|
||||||
# only after .type_class()
|
# only after .type_class()
|
||||||
@@ -251,6 +251,8 @@ class AuthoringData:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def predefined_type(cls):
|
def predefined_type(cls):
|
||||||
|
if not tool.Blender.enum_property_has_valid_index(cls.props, "relating_type_id", cls.data["relating_type_id"]):
|
||||||
|
return
|
||||||
relating_type_id = cls.props.relating_type_id
|
relating_type_id = cls.props.relating_type_id
|
||||||
if not relating_type_id:
|
if not relating_type_id:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -472,11 +472,16 @@ class Blender(blenderbim.core.tool.Blender):
|
|||||||
"""method created for readibility and to avoid console warnings like
|
"""method created for readibility and to avoid console warnings like
|
||||||
`pyrna_enum_to_py: current value '17' matches no enum in 'BIMModelProperties', '', 'relating_type_id'`
|
`pyrna_enum_to_py: current value '17' matches no enum in 'BIMModelProperties', '', 'relating_type_id'`
|
||||||
"""
|
"""
|
||||||
|
items_amount = len(enum_items)
|
||||||
|
# If enum has no items it seems to always produce a warning.
|
||||||
|
# E.g. if you try to get it's value directly: `BIMModelProperties.relating_type_id`.
|
||||||
|
if items_amount == 0:
|
||||||
|
return False
|
||||||
current_value_index = props.get(prop_name, None)
|
current_value_index = props.get(prop_name, None)
|
||||||
# assuming the default value is fine
|
# assuming the default value is fine
|
||||||
if current_value_index is None:
|
if current_value_index is None:
|
||||||
return True
|
return True
|
||||||
return current_value_index < len(enum_items)
|
return current_value_index < items_amount
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def append_data_block(cls, filepath: str, data_block_type: str, name: str, link=False, relative=False) -> dict:
|
def append_data_block(cls, filepath: str, data_block_type: str, name: str, link=False, relative=False) -> dict:
|
||||||
|
|||||||
Reference in New Issue
Block a user