diff --git a/src/blenderbim/blenderbim/bim/module/model/product.py b/src/blenderbim/blenderbim/bim/module/model/product.py index adec92d59a..0f5ef1da27 100644 --- a/src/blenderbim/blenderbim/bim/module/model/product.py +++ b/src/blenderbim/blenderbim/bim/module/model/product.py @@ -201,7 +201,9 @@ class ChangeTypePage(bpy.types.Operator, tool.Ifc.Operator): page: bpy.props.IntProperty() def _execute(self, context): - context.scene.BIMModelProperties.type_page = self.page + props = context.scene.BIMModelProperties + bpy.ops.bim.load_type_thumbnails(ifc_class=props.type_class, offset=9 * (self.page - 1), limit=9) + props.type_page = self.page return {"FINISHED"} @@ -316,14 +318,24 @@ class LoadTypeThumbnails(bpy.types.Operator, tool.Ifc.Operator): bl_label = "Load Type Thumbnails" bl_options = {"REGISTER", "UNDO"} ifc_class: bpy.props.StringProperty() + limit: bpy.props.IntProperty() + offset: bpy.props.IntProperty() def _execute(self, context): from PIL import Image, ImageDraw + props = bpy.context.scene.BIMModelProperties processing = set() - # Only process at most one class at a time. + # Only process at most one paginated class at a time. # Large projects have hundreds of types which can lead to unnecessary lag. - queue = tool.Ifc.get().by_type(self.ifc_class) + queue = sorted(tool.Ifc.get().by_type(self.ifc_class), key=lambda e: e.Name or "Unnamed") + if self.limit: + queue = queue[self.offset:self.offset + self.limit] + else: + offset = 9 * (props.type_page - 1) + if offset < 0: + offset = 0 + queue = queue[offset:offset + 9] unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) diff --git a/src/blenderbim/blenderbim/bim/module/model/ui.py b/src/blenderbim/blenderbim/bim/module/model/ui.py index b172d667f7..d62bf9ee4f 100644 --- a/src/blenderbim/blenderbim/bim/module/model/ui.py +++ b/src/blenderbim/blenderbim/bim/module/model/ui.py @@ -38,7 +38,7 @@ class LaunchTypeManager(bpy.types.Operator): props.type_page = 1 if props.ifc_class: props.type_class = props.ifc_class - bpy.ops.bim.load_type_thumbnails(ifc_class=props.ifc_class) + bpy.ops.bim.load_type_thumbnails(ifc_class=props.ifc_class, offset=0, limit=9) if not AuthoringData.is_loaded: AuthoringData.load() return context.window_manager.invoke_popup(self, width=550) diff --git a/src/blenderbim/blenderbim/tool/project.py b/src/blenderbim/blenderbim/tool/project.py index 585da491be..75e2c0e820 100644 --- a/src/blenderbim/blenderbim/tool/project.py +++ b/src/blenderbim/blenderbim/tool/project.py @@ -42,7 +42,7 @@ class Project(blenderbim.core.tool.Project): def load_default_thumbnails(cls): if tool.Ifc.get().by_type("IfcElementType"): ifc_class = sorted(tool.Ifc.get().by_type("IfcElementType"), key=lambda e: e.is_a())[0].is_a() - bpy.ops.bim.load_type_thumbnails(ifc_class=ifc_class) + bpy.ops.bim.load_type_thumbnails(ifc_class=ifc_class, offset=0, limit=9) @classmethod def run_aggregate_assign_object(cls, relating_obj=None, related_obj=None):