Add AuthoringData.data["ifc_class_current"] to model data.

This commit is contained in:
Bruno Perdigão
2024-11-08 09:52:50 -03:00
committed by Bruno Perdigão
parent 66ded3fc41
commit 084c2aa25a
3 changed files with 17 additions and 15 deletions
+12 -6
View File
@@ -56,6 +56,7 @@ class AuthoringData:
cls.data["default_container"] = cls.default_container()
cls.data["ifc_element_type"] = cls.ifc_element_type
cls.data["ifc_classes"] = cls.ifc_classes()
cls.data["ifc_class_current"] = cls.ifc_class_current()
cls.data["relating_type_id"] = cls.relating_type_id() # only after .ifc_classes()
cls.data["relating_type_name"] = cls.relating_type_name() # only after .relating_type_id()
cls.data["relating_type_description"] = cls.relating_type_description() # only after .relating_type_id()
@@ -108,12 +109,12 @@ class AuthoringData:
@classmethod
def total_types(cls):
ifc_class = cls.props.ifc_class
ifc_class = cls.data["ifc_class_current"]
return len(tool.Ifc.get().by_type(ifc_class)) if ifc_class else 0
@classmethod
def total_pages(cls):
ifc_class = cls.props.ifc_class
ifc_class = cls.data["ifc_class_current"]
total_types = len(tool.Ifc.get().by_type(ifc_class)) if ifc_class else 0
return math.ceil(total_types / cls.types_per_page)
@@ -129,7 +130,7 @@ class AuthoringData:
@classmethod
def paginated_relating_types(cls):
ifc_class = cls.props.ifc_class
ifc_class = cls.data["ifc_class_current"]
if not ifc_class:
return []
results = []
@@ -226,15 +227,20 @@ class AuthoringData:
results.extend([(c, c, "") for c in sorted(classes)])
return results
@classmethod
def relating_type_id(cls):
@classmethod
def ifc_class_current(cls):
ifc_classes = cls.data["ifc_classes"]
if not ifc_classes:
return []
results = []
ifc_class = tool.Blender.get_enum_safe(cls.props, "ifc_class")
if not ifc_class and ifc_classes:
ifc_class = ifc_classes[0][0]
return ifc_class
@classmethod
def relating_type_id(cls):
results = []
ifc_class = cls.data["ifc_class_current"]
if ifc_class:
elements = natsorted(tool.Ifc.get().by_type(ifc_class), key=lambda s: (s.Name or "Unnamed").lower())
results.extend(elements)
+2 -2
View File
@@ -94,7 +94,7 @@ class LaunchTypeManager(bpy.types.Operator):
props = context.scene.BIMModelProperties
props.type_page = 1
if get_ifc_class(None, context):
ifc_class = props.ifc_class or AuthoringData.data["ifc_element_type"]
ifc_class = AuthoringData.data["ifc_class_current"] or AuthoringData.data["ifc_element_type"]
else:
ifc_class = AuthoringData.data["ifc_element_type"]
@@ -167,7 +167,7 @@ class LaunchTypeManager(bpy.types.Operator):
else:
row = box.row()
op = box.operator("bim.load_type_thumbnails", text="", icon="FILE_REFRESH", emboss=False)
op.ifc_class = props.ifc_class
op.ifc_class = AuthoringData.data["ifc_class_current"]
row = box.row()
row.alignment = "CENTER"
@@ -433,9 +433,7 @@ class CreateObjectUI:
if not AuthoringData.data["relating_type_id"]:
return
ifc_class = tool.Blender.get_enum_safe(cls.props, "ifc_class")
if not ifc_class:
ifc_class = AuthoringData.data["ifc_classes"][0][0]
ifc_class = AuthoringData.data["ifc_class_current"]
if ifc_class == "IfcWallType":
row.prop(data=cls.props, property="rl1", text="Relative Level" if ui_context != "TOOL_HEADER" else "RL")
row = cls.layout.row(align=True) if ui_context != "TOOL_HEADER" else row
@@ -488,9 +486,7 @@ class CreateObjectUI:
if not AuthoringData.data["ifc_element_type"]:
prop_with_search(row, cls.props, "ifc_class", text="Type Class" if ui_context != "TOOL_HEADER" else "")
if AuthoringData.data["ifc_classes"]:
ifc_class = tool.Blender.get_enum_safe(cls.props, "ifc_class")
if not ifc_class:
ifc_class = AuthoringData.data["ifc_classes"][0][0]
ifc_class = AuthoringData.data["ifc_class_current"]
if ifc_class:
box = cls.layout.box()
row = box.row(align=True)
@@ -916,7 +912,7 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
if get_ifc_class(None, None):
try:
self.has_ifc_class = bool(self.props.ifc_class)
self.has_ifc_class = bool(tool.Blender.get_enum_safe(self.props, "ifc_class"))
except:
pass
getattr(self, f"hotkey_{self.hotkey}")()