mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Load thumbnails in a paginated manner to allow to scale to larger models
This commit is contained in:
@@ -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())
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user