mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
Add AuthoringData.data["ifc_class_current"] to model data.
This commit is contained in:
committed by
Bruno Perdigão
parent
66ded3fc41
commit
084c2aa25a
@@ -56,6 +56,7 @@ class AuthoringData:
|
|||||||
cls.data["default_container"] = cls.default_container()
|
cls.data["default_container"] = cls.default_container()
|
||||||
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["ifc_class_current"] = cls.ifc_class_current()
|
||||||
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["relating_type_name"] = cls.relating_type_name() # only after .relating_type_id()
|
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()
|
cls.data["relating_type_description"] = cls.relating_type_description() # only after .relating_type_id()
|
||||||
@@ -108,12 +109,12 @@ class AuthoringData:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def total_types(cls):
|
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
|
return len(tool.Ifc.get().by_type(ifc_class)) if ifc_class else 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def total_pages(cls):
|
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
|
total_types = len(tool.Ifc.get().by_type(ifc_class)) if ifc_class else 0
|
||||||
return math.ceil(total_types / cls.types_per_page)
|
return math.ceil(total_types / cls.types_per_page)
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ class AuthoringData:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def paginated_relating_types(cls):
|
def paginated_relating_types(cls):
|
||||||
ifc_class = cls.props.ifc_class
|
ifc_class = cls.data["ifc_class_current"]
|
||||||
if not ifc_class:
|
if not ifc_class:
|
||||||
return []
|
return []
|
||||||
results = []
|
results = []
|
||||||
@@ -227,14 +228,19 @@ class AuthoringData:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def relating_type_id(cls):
|
def ifc_class_current(cls):
|
||||||
ifc_classes = cls.data["ifc_classes"]
|
ifc_classes = cls.data["ifc_classes"]
|
||||||
if not ifc_classes:
|
if not ifc_classes:
|
||||||
return []
|
return []
|
||||||
results = []
|
|
||||||
ifc_class = tool.Blender.get_enum_safe(cls.props, "ifc_class")
|
ifc_class = tool.Blender.get_enum_safe(cls.props, "ifc_class")
|
||||||
if not ifc_class and ifc_classes:
|
if not ifc_class and ifc_classes:
|
||||||
ifc_class = ifc_classes[0][0]
|
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:
|
if ifc_class:
|
||||||
elements = natsorted(tool.Ifc.get().by_type(ifc_class), key=lambda s: (s.Name or "Unnamed").lower())
|
elements = natsorted(tool.Ifc.get().by_type(ifc_class), key=lambda s: (s.Name or "Unnamed").lower())
|
||||||
results.extend(elements)
|
results.extend(elements)
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class LaunchTypeManager(bpy.types.Operator):
|
|||||||
props = context.scene.BIMModelProperties
|
props = context.scene.BIMModelProperties
|
||||||
props.type_page = 1
|
props.type_page = 1
|
||||||
if get_ifc_class(None, context):
|
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:
|
else:
|
||||||
ifc_class = AuthoringData.data["ifc_element_type"]
|
ifc_class = AuthoringData.data["ifc_element_type"]
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ class LaunchTypeManager(bpy.types.Operator):
|
|||||||
else:
|
else:
|
||||||
row = box.row()
|
row = box.row()
|
||||||
op = box.operator("bim.load_type_thumbnails", text="", icon="FILE_REFRESH", emboss=False)
|
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 = box.row()
|
||||||
row.alignment = "CENTER"
|
row.alignment = "CENTER"
|
||||||
|
|||||||
@@ -433,9 +433,7 @@ class CreateObjectUI:
|
|||||||
if not AuthoringData.data["relating_type_id"]:
|
if not AuthoringData.data["relating_type_id"]:
|
||||||
return
|
return
|
||||||
|
|
||||||
ifc_class = tool.Blender.get_enum_safe(cls.props, "ifc_class")
|
ifc_class = AuthoringData.data["ifc_class_current"]
|
||||||
if not ifc_class:
|
|
||||||
ifc_class = AuthoringData.data["ifc_classes"][0][0]
|
|
||||||
if ifc_class == "IfcWallType":
|
if ifc_class == "IfcWallType":
|
||||||
row.prop(data=cls.props, property="rl1", text="Relative Level" if ui_context != "TOOL_HEADER" else "RL")
|
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
|
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"]:
|
if not AuthoringData.data["ifc_element_type"]:
|
||||||
prop_with_search(row, cls.props, "ifc_class", text="Type Class" if ui_context != "TOOL_HEADER" else "")
|
prop_with_search(row, cls.props, "ifc_class", text="Type Class" if ui_context != "TOOL_HEADER" else "")
|
||||||
if AuthoringData.data["ifc_classes"]:
|
if AuthoringData.data["ifc_classes"]:
|
||||||
ifc_class = tool.Blender.get_enum_safe(cls.props, "ifc_class")
|
ifc_class = AuthoringData.data["ifc_class_current"]
|
||||||
if not ifc_class:
|
|
||||||
ifc_class = AuthoringData.data["ifc_classes"][0][0]
|
|
||||||
if ifc_class:
|
if ifc_class:
|
||||||
box = cls.layout.box()
|
box = cls.layout.box()
|
||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
@@ -916,7 +912,7 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
if get_ifc_class(None, None):
|
if get_ifc_class(None, None):
|
||||||
try:
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
getattr(self, f"hotkey_{self.hotkey}")()
|
getattr(self, f"hotkey_{self.hotkey}")()
|
||||||
|
|||||||
Reference in New Issue
Block a user