2011-02-18 08:47:37 +00:00
|
|
|
"""
|
2012-06-28 08:17:28 +00:00
|
|
|
Overriding Context
|
|
|
|
------------------
|
2011-02-18 08:47:37 +00:00
|
|
|
|
2012-06-28 08:17:28 +00:00
|
|
|
It is possible to override context members that the operator sees, so that they
|
|
|
|
act on specified rather than the selected or active data, or to execute an
|
|
|
|
operator in the different part of the user interface.
|
2011-02-18 08:47:37 +00:00
|
|
|
|
2012-06-28 08:17:28 +00:00
|
|
|
The context overrides are passed as a dictionary, with keys matching the context
|
2015-09-08 14:30:05 +10:00
|
|
|
member names in bpy.context.
|
|
|
|
For example to override ``bpy.context.active_object``,
|
2022-04-20 12:49:13 +10:00
|
|
|
you would pass ``{'active_object': object}`` to :class:`bpy.types.Context.temp_override`.
|
2016-02-14 18:26:34 +01:00
|
|
|
|
|
|
|
.. note::
|
2016-02-15 19:37:37 +11:00
|
|
|
|
2016-02-14 18:26:34 +01:00
|
|
|
You will nearly always want to use a copy of the actual current context as basis
|
|
|
|
(otherwise, you'll have to find and gather all needed data yourself).
|
2011-02-18 08:47:37 +00:00
|
|
|
"""
|
|
|
|
|
2022-04-20 12:49:13 +10:00
|
|
|
# Remove all objects in scene rather than the selected ones.
|
2011-02-18 08:47:37 +00:00
|
|
|
import bpy
|
2022-04-20 12:49:13 +10:00
|
|
|
from bpy import context
|
2023-05-23 14:34:09 +10:00
|
|
|
context_override = context.copy()
|
|
|
|
context_override["selected_objects"] = list(context.scene.objects)
|
|
|
|
with context.temp_override(**context_override):
|
2022-04-20 12:49:13 +10:00
|
|
|
bpy.ops.object.delete()
|