mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +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.core.debug as core
|
||||||
import blenderbim.bim.handler
|
import blenderbim.bim.handler
|
||||||
import blenderbim.bim.import_ifc as import_ifc
|
import blenderbim.bim.import_ifc as import_ifc
|
||||||
|
from pathlib import Path
|
||||||
from blenderbim import get_debug_info, format_debug_info
|
from blenderbim import get_debug_info, format_debug_info
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
|
|
||||||
@@ -139,20 +140,30 @@ class ValidateIfcFile(bpy.types.Operator):
|
|||||||
|
|
||||||
|
|
||||||
class ProfileImportIFC(bpy.types.Operator):
|
class ProfileImportIFC(bpy.types.Operator):
|
||||||
|
profile_filename = "blender.prof"
|
||||||
bl_idname = "bim.profile_import_ifc"
|
bl_idname = "bim.profile_import_ifc"
|
||||||
bl_label = "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
|
@classmethod
|
||||||
def poll(cls, context):
|
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):
|
def execute(self, context):
|
||||||
import cProfile
|
import cProfile
|
||||||
import pstats
|
import pstats
|
||||||
|
|
||||||
cProfile.run("import bpy; bpy.ops.bim.load_project_elements()", "blender.prof")
|
profile_file = Path(profile_filename)
|
||||||
p = pstats.Stats("blender.prof")
|
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)
|
p.sort_stats("cumulative").print_stats(50)
|
||||||
|
self.report({"INFO"}, f'Profile stats are saved to "{profile_file.absolute()}".')
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user