diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-11-14 06:01:02 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-11-14 06:01:02 +0400 |
commit | 6cee7bb2b77bc7b577a3067c30dc56e22b4752ce (patch) | |
tree | ab504ed0ffa59eb68ed1b57f2208dd949cf40fda /doc/python_api | |
parent | 872af481831650f2399c85df2ed059d58c5210be (diff) | |
parent | de5d0d649da9b73de96cbee9015b838e3c0389c1 (diff) |
Merged changes in the trunk up to revision 52191.
Conflicts resolved:
source/blender/makesdna/DNA_scene_types.h
Diffstat (limited to 'doc/python_api')
-rw-r--r-- | doc/python_api/rst/bge.types.rst | 6 | ||||
-rw-r--r-- | doc/python_api/rst/info_gotcha.rst | 57 |
2 files changed, 50 insertions, 13 deletions
diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index 7ce913a54f3..15d188e0734 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -989,13 +989,13 @@ Types :type: :class:`KX_GameObject` or None - .. attribute:: group_children + .. attribute:: groupMembers Returns the list of group members if the object is a group object, otherwise None is returned. :type: :class:`CListValue` of :class:`KX_GameObject` or None - .. attribute:: group_parent + .. attribute:: groupObject Returns the group object that the object belongs to or None if the object is not part of a group. @@ -1966,7 +1966,7 @@ Types :arg matrix: transformation matrix. :type matrix: 4x4 matrix [[float]] - .. method:: transform_uv(matid, matrix, uv_index=-1, uv_index_from=-1) + .. method:: transformUV(matid, matrix, uv_index=-1, uv_index_from=-1) Transforms the vertices UV's of a mesh. diff --git a/doc/python_api/rst/info_gotcha.rst b/doc/python_api/rst/info_gotcha.rst index 1d561216b52..e60f1e256cd 100644 --- a/doc/python_api/rst/info_gotcha.rst +++ b/doc/python_api/rst/info_gotcha.rst @@ -118,18 +118,19 @@ If you insist - yes its possible, but scripts that use this hack wont be conside bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) -I can't edit the mesh in edit-mode! -=================================== +Modes and Mesh Access +===================== -Blender's EditMesh is an internal data structure (not saved and not exposed to python), this gives the main annoyance that you need to exit edit-mode to edit the mesh from python. +When working with mesh data you may run into the problem where a script fails to run as expected in edit-mode. This is caused by edit-mode having its own data which is only written back to the mesh when exiting edit-mode. -The reason we have not made much attempt to fix this yet is because we -will likely move to BMesh mesh API eventually, so any work on the API now will be wasted effort. +A common example is that exporters may access a mesh through ``obj.data`` (a :class:`bpy.types.Mesh`) but the user is in edit-mode, where the mesh data is available but out of sync with the edit mesh. -With the BMesh API we may expose mesh data to python so we can -write useful tools in python which are also fast to execute while in edit-mode. +In this situation you can... -For the time being this limitation just has to be worked around but we're aware its frustrating needs to be addressed. +* Exit edit-mode before running the tool. +* Explicitly update the mesh by calling :class:`bmesh.types.BMesh.to_mesh`. +* Modify the script to support working on the edit-mode data directly, see: :mod:`bmesh.from_edit_mesh`. +* Report the context as incorrect and only allow the script to run outside edit-mode. .. _info_gotcha_mesh_faces: @@ -311,7 +312,7 @@ Naming Limitations A common mistake is to assume newly created data is given the requested name. -This can cause bugs when you add some data (normally imported) and then reference it later by name. +This can cause bugs when you add some data (normally imported) then reference it later by name. .. code-block:: python @@ -557,6 +558,21 @@ 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. +Undo & Library Data +^^^^^^^^^^^^^^^^^^^ + +One of the advantages with Blenders library linking system that undo can skip checking changes in library data since it is assumed to be static. + +Tools in Blender are not allowed to modify library data. + +Python however does not enforce this restriction. + +This can be useful in some cases, using a script to adjust material values for example. +But its also possible to use a script to make library data point to newly created local data, which is not supported since a call to undo will remove the local data but leave the library referencing it and likely crash. + +So it's best to consider modifying library data an advanced usage of the API and only to use it when you know what you're doing. + + Edit Mode / Memory Access ------------------------- @@ -616,7 +632,28 @@ Removing Data **Any** data that you remove shouldn't be modified or accessed afterwards, this includes f-curves, drivers, render layers, timeline markers, modifiers, constraints along with objects, scenes, groups, bones.. etc. -This is a problem in the API at the moment that we should eventually solve. +The ``remove()`` api calls will invalidate the data they free to prevent common mistakes. + +The following example shows how this precortion works. + +.. code-block:: python + + mesh = bpy.data.meshes.new(name="MyMesh") + # normally the script would use the mesh here... + bpy.data.meshes.remove(mesh) + print(mesh.name) # <- give an exception rather then crashing: + + # ReferenceError: StructRNA of type Mesh has been removed + + +But take care because this is limited to scripts accessing the variable which is removed, the next example will still crash. + +.. code-block:: python + + mesh = bpy.data.meshes.new(name="MyMesh") + vertices = mesh.vertices + bpy.data.meshes.remove(mesh) + print(vertices) # <- this may crash sys.exit |