Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-09-11 03:06:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-11 03:06:44 +0400
commit1e6dbb1a4d320fb34a8f0c85329484153062f8a5 (patch)
tree91ecb1f40ef0e706493eaf6ac75ca9bcf4aac2d1 /doc
parentfbf3a76f1d4b50b81334f55efbff7a1e6ba1f413 (diff)
added section about editmode switching to gotchas
Diffstat (limited to 'doc')
-rw-r--r--doc/python_api/rst/info_gotcha.rst35
1 files changed, 35 insertions, 0 deletions
diff --git a/doc/python_api/rst/info_gotcha.rst b/doc/python_api/rst/info_gotcha.rst
index 47dd04853bd..e7903dcf96a 100644
--- a/doc/python_api/rst/info_gotcha.rst
+++ b/doc/python_api/rst/info_gotcha.rst
@@ -378,6 +378,41 @@ This example shows how you can tell undo changes the memory locations.
As suggested above, simply not holding references to data when Blender is used interactively by the user is the only way to ensure the script doesn't become unstable.
+Edit Mode / Memory Access
+-------------------------
+
+Switching edit-mode ``bpy.ops.object.mode_set(mode='EDIT')`` / ``bpy.ops.object.mode_set(mode='OBJECT')`` will re-allocate objects data, any references to a meshes vertices/faces/uvs, armatures bones, curves points etc cannot be accessed after switching edit-mode.
+
+Only the reference to the data its self can be re-accessed, the following example will crash.
+
+.. code-block:: python
+
+ mesh = bpy.context.active_object.data
+ faces = mesh.faces
+ bpy.ops.object.mode_set(mode='EDIT')
+ bpy.ops.object.mode_set(mode='OBJECT')
+
+ # this will crash
+ print(faces)
+
+
+So after switching edit-mode you need to re-access any object data variables, the following example shows how to avoid the crash above.
+
+.. code-block:: python
+
+ mesh = bpy.context.active_object.data
+ faces = mesh.faces
+ bpy.ops.object.mode_set(mode='EDIT')
+ bpy.ops.object.mode_set(mode='OBJECT')
+
+ # faces have been re-allocated
+ faces = mesh.faces
+ print(faces)
+
+
+These kinds of problems can happen for any functions which re-allocate the object data but are most common when switching edit-mode.
+
+
Array Re-Allocation
-------------------