diff options
author | Aaron Carlisle <carlisle.b3d@gmail.com> | 2020-02-10 22:08:34 +0300 |
---|---|---|
committer | Aaron Carlisle <carlisle.b3d@gmail.com> | 2020-02-10 22:08:34 +0300 |
commit | 189e96ba687c88bf40f86ba64e5054c70ebde95b (patch) | |
tree | 1426a6a55ffb9d8bdb8446a77221e1ca6a11d090 /doc/python_api/rst | |
parent | 974dc284761338da477fc1e4e901b6ad1b82805f (diff) |
Fix T72883: Correct Context Usage
Diffstat (limited to 'doc/python_api/rst')
-rw-r--r-- | doc/python_api/rst/info_quickstart.rst | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/doc/python_api/rst/info_quickstart.rst b/doc/python_api/rst/info_quickstart.rst index 75aeb765f53..996169a5227 100644 --- a/doc/python_api/rst/info_quickstart.rst +++ b/doc/python_api/rst/info_quickstart.rst @@ -228,13 +228,16 @@ Note that the context is read-only. These values cannot be modified directly, though they may be changed by running API functions or by using the data API. -So ``bpy.context.object = obj`` will raise an error. +So ``bpy.context.active_object = obj`` will raise an error. -But ``bpy.context.scene.objects.active = obj`` will work as expected. +But the following will work as expected: + >>> obj = bpy.data.objects["Cube"] + >>> obj.select_set(state = True, view_layer = bpy.context.view_layer) + >>> bpy.context.view_layer.objects.active = obj The context attributes change depending on where they are accessed. -The 3D view has different context members than the console, +The 3D Viewport has different context members than the Python Console, so take care when accessing context attributes that the user state is known. See :mod:`bpy.context` API reference. |