mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-30 16:43:00 +00:00
Minor fix. It seems as though StructRNA of type Scene may be removed during undo/redo, which results in handlers failing.
This commit is contained in:
@@ -166,8 +166,8 @@ def undo_pre(scene):
|
|||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def undo_post(scene):
|
def undo_post(scene):
|
||||||
if IfcStore.last_transaction != scene.BIMProperties.last_transaction:
|
if IfcStore.last_transaction != bpy.context.scene.BIMProperties.last_transaction:
|
||||||
IfcStore.last_transaction = scene.BIMProperties.last_transaction
|
IfcStore.last_transaction = bpy.context.scene.BIMProperties.last_transaction
|
||||||
IfcStore.undo()
|
IfcStore.undo()
|
||||||
purge_module_data()
|
purge_module_data()
|
||||||
IfcStore.update_undo_redo_stack_objects()
|
IfcStore.update_undo_redo_stack_objects()
|
||||||
@@ -181,10 +181,8 @@ def redo_pre(scene):
|
|||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def redo_post(scene):
|
def redo_post(scene):
|
||||||
if scene is None:
|
if IfcStore.last_transaction != bpy.context.scene.BIMProperties.last_transaction:
|
||||||
scene = bpy.context.scene
|
IfcStore.last_transaction = bpy.context.scene.BIMProperties.last_transaction
|
||||||
if IfcStore.last_transaction != scene.BIMProperties.last_transaction:
|
|
||||||
IfcStore.last_transaction = scene.BIMProperties.last_transaction
|
|
||||||
IfcStore.redo()
|
IfcStore.redo()
|
||||||
purge_module_data()
|
purge_module_data()
|
||||||
IfcStore.update_undo_redo_stack_objects()
|
IfcStore.update_undo_redo_stack_objects()
|
||||||
@@ -193,9 +191,7 @@ def redo_post(scene):
|
|||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def ensureIfcExported(scene):
|
def ensureIfcExported(scene):
|
||||||
if scene is None:
|
if IfcStore.get_file() and not bpy.context.scene.BIMProperties.ifc_file:
|
||||||
scene = bpy.context.scene
|
|
||||||
if IfcStore.get_file() and not scene.BIMProperties.ifc_file:
|
|
||||||
bpy.ops.export_ifc.bim("INVOKE_DEFAULT")
|
bpy.ops.export_ifc.bim("INVOKE_DEFAULT")
|
||||||
|
|
||||||
|
|
||||||
@@ -228,26 +224,24 @@ def get_application_version():
|
|||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def setDefaultProperties(scene):
|
def setDefaultProperties(scene):
|
||||||
if scene is None:
|
|
||||||
scene = bpy.context.scene
|
|
||||||
global global_subscription_owner
|
global global_subscription_owner
|
||||||
active_object_key = bpy.types.LayerObjects, "active"
|
active_object_key = bpy.types.LayerObjects, "active"
|
||||||
bpy.msgbus.subscribe_rna(
|
bpy.msgbus.subscribe_rna(
|
||||||
key=active_object_key, owner=global_subscription_owner, args=(), notify=active_object_callback
|
key=active_object_key, owner=global_subscription_owner, args=(), notify=active_object_callback
|
||||||
)
|
)
|
||||||
ifcopenshell.api.owner.settings.get_person = (
|
ifcopenshell.api.owner.settings.get_person = (
|
||||||
lambda ifc: ifc.by_id(int(scene.BIMOwnerProperties.user_person))
|
lambda ifc: ifc.by_id(int(bpy.context.scene.BIMOwnerProperties.user_person))
|
||||||
if getPersons(None, None) and scene.BIMOwnerProperties.user_person
|
if getPersons(None, None) and bpy.context.scene.BIMOwnerProperties.user_person
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
ifcopenshell.api.owner.settings.get_organisation = (
|
ifcopenshell.api.owner.settings.get_organisation = (
|
||||||
lambda ifc: ifc.by_id(int(scene.BIMOwnerProperties.user_organisation))
|
lambda ifc: ifc.by_id(int(bpy.context.scene.BIMOwnerProperties.user_organisation))
|
||||||
if getOrganisations(None, None) and scene.BIMOwnerProperties.user_organisation
|
if getOrganisations(None, None) and bpy.context.scene.BIMOwnerProperties.user_organisation
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
ifcopenshell.api.owner.settings.get_application = get_application
|
ifcopenshell.api.owner.settings.get_application = get_application
|
||||||
if len(scene.DocProperties.drawing_styles) == 0:
|
if len(bpy.context.scene.DocProperties.drawing_styles) == 0:
|
||||||
drawing_style = scene.DocProperties.drawing_styles.add()
|
drawing_style = bpy.context.scene.DocProperties.drawing_styles.add()
|
||||||
drawing_style.name = "Technical"
|
drawing_style.name = "Technical"
|
||||||
drawing_style.render_type = "VIEWPORT"
|
drawing_style.render_type = "VIEWPORT"
|
||||||
drawing_style.raster_style = json.dumps(
|
drawing_style.raster_style = json.dumps(
|
||||||
@@ -278,7 +272,7 @@ def setDefaultProperties(scene):
|
|||||||
RasterStyleProperty.OVERLAY_SHOW_RELATIONSHIP_LINES.value: False,
|
RasterStyleProperty.OVERLAY_SHOW_RELATIONSHIP_LINES.value: False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
drawing_style = scene.DocProperties.drawing_styles.add()
|
drawing_style = bpy.context.scene.DocProperties.drawing_styles.add()
|
||||||
drawing_style.name = "Shaded"
|
drawing_style.name = "Shaded"
|
||||||
drawing_style.render_type = "VIEWPORT"
|
drawing_style.render_type = "VIEWPORT"
|
||||||
drawing_style.raster_style = json.dumps(
|
drawing_style.raster_style = json.dumps(
|
||||||
@@ -309,7 +303,7 @@ def setDefaultProperties(scene):
|
|||||||
RasterStyleProperty.OVERLAY_SHOW_RELATIONSHIP_LINES.value: False,
|
RasterStyleProperty.OVERLAY_SHOW_RELATIONSHIP_LINES.value: False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
drawing_style = scene.DocProperties.drawing_styles.add()
|
drawing_style = bpy.context.scene.DocProperties.drawing_styles.add()
|
||||||
drawing_style.name = "Blender Default"
|
drawing_style.name = "Blender Default"
|
||||||
drawing_style.render_type = "DEFAULT"
|
drawing_style.render_type = "DEFAULT"
|
||||||
bpy.ops.bim.save_drawing_style(index="2")
|
bpy.ops.bim.save_drawing_style(index="2")
|
||||||
|
|||||||
Reference in New Issue
Block a user