mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-08 17:01:40 +00:00
make bim.profile_import_ifc a bit more friendly
This commit is contained in:
@@ -34,6 +34,7 @@ import blenderbim.tool as tool
|
||||
import blenderbim.core.debug as core
|
||||
import blenderbim.bim.handler
|
||||
import blenderbim.bim.import_ifc as import_ifc
|
||||
from pathlib import Path
|
||||
from blenderbim import get_debug_info, format_debug_info
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
@@ -139,20 +140,30 @@ class ValidateIfcFile(bpy.types.Operator):
|
||||
|
||||
|
||||
class ProfileImportIFC(bpy.types.Operator):
|
||||
profile_filename = "blender.prof"
|
||||
bl_idname = "bim.profile_import_ifc"
|
||||
bl_label = "Profile Import IFC"
|
||||
bl_description = f"Reload currently loaded project and save cprofile stats for reloading to '{profile_filename}'"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return IfcStore.get_file() and context.scene.BIMProperties.ifc_file
|
||||
if not tool.Ifc.get():
|
||||
cls.poll_message_set("No IFC file loaded.")
|
||||
return False
|
||||
if not context.scene.BIMProperties.ifc_file:
|
||||
cls.poll_message_set("Current IFC file is not saved.")
|
||||
return False
|
||||
return True
|
||||
|
||||
def execute(self, context):
|
||||
import cProfile
|
||||
import pstats
|
||||
|
||||
cProfile.run("import bpy; bpy.ops.bim.load_project_elements()", "blender.prof")
|
||||
p = pstats.Stats("blender.prof")
|
||||
profile_file = Path(profile_filename)
|
||||
cProfile.run("import bpy; bpy.ops.bim.load_project_elements()", str(profile_file))
|
||||
p = pstats.Stats(str(profile_file))
|
||||
p.sort_stats("cumulative").print_stats(50)
|
||||
self.report({"INFO"}, f'Profile stats are saved to "{profile_file.absolute()}".')
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user