diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-04-29 04:59:04 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-04-29 04:59:04 +0400 |
commit | 2585d524057da908668bb6d5ff7ec8b344d23093 (patch) | |
tree | 2494aaa2281e568e4904fbe419f6a032535c65ad /doc/python_api | |
parent | d8e12e8710f7c24e046c132e84eff416b8e8d06c (diff) | |
parent | 4465d2f419a8515df41a8fc415774eedaef0e6f6 (diff) |
Merged changes in the trunk up to revision 46045.
Conflicts resolved:
doc/python_api/sphinx_doc_gen.py
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/makesdna/DNA_scene_types.h
Diffstat (limited to 'doc/python_api')
-rw-r--r-- | doc/python_api/examples/bpy.types.Mesh.py | 41 | ||||
-rw-r--r-- | doc/python_api/rst/include__bmesh.rst | 13 | ||||
-rw-r--r-- | doc/python_api/rst/info_gotcha.rst | 2 | ||||
-rw-r--r-- | doc/python_api/sphinx_doc_gen.py | 21 |
4 files changed, 65 insertions, 12 deletions
diff --git a/doc/python_api/examples/bpy.types.Mesh.py b/doc/python_api/examples/bpy.types.Mesh.py new file mode 100644 index 00000000000..69edf2cba50 --- /dev/null +++ b/doc/python_api/examples/bpy.types.Mesh.py @@ -0,0 +1,41 @@ +""" +Mesh Data ++++++++++ + +The mesh data is accessed in object mode and intended for compact storage, +for more flexible mesh editing from python see :mod:`bmesh`. + +Blender stores 4 main arrays to define mesh geometry. + +* :class:`Mesh.vertices` (3 points in space) +* :class:`Mesh.edges` (reference 2 vertices) +* :class:`Mesh.loops` (reference a single vertex and edge) +* :class:`Mesh.polygons`: (reference a range of loops) + + +Each polygon reference a slice in the loop array, this way, polygons do not store vertices or corner data such as UV's directly, +only a reference to loops that the polygon uses. + +:class:`Mesh.loops`, :class:`Mesh.uv_layers` :class:`Mesh.vertex_colors` are all aligned so the same polygon loop +indicies can be used to find the UV's and vertex colors as with as the vertices. + +To compare mesh API options see: :ref:`NGons and Tessellation Faces <info_gotcha_mesh_faces>` + + +This example script prints the vertices and UV's for each polygon, assumes the active object is a mesh with UVs. +""" + +import bpy + +me = bpy.context.object.data +uv_layer = me.uv.layers.active.data + +for poly in me.polygons: + print("Polygon index: %d, length: %d" % (poly.index, poly.loop_total)) + + # range is used here to show how the polygons reference loops, + # for convenience 'poly.loop_indices' can be used instead. + for loop_index in range(poly.loop_start, poly.loop_start + poly.loop_total): + print(" Vertex: %d" % me.loops[loop_index].vertex_index) + print(" UV: %r" % uv_layer[loop_index].uv) + diff --git a/doc/python_api/rst/include__bmesh.rst b/doc/python_api/rst/include__bmesh.rst index 24f113e7b50..212ab4e4708 100644 --- a/doc/python_api/rst/include__bmesh.rst +++ b/doc/python_api/rst/include__bmesh.rst @@ -32,12 +32,11 @@ For an overview of BMesh data types and how they reference each other see: .. warning:: - TODO Items Are + TODO items are... * add access to BMesh **walkers** - * add a way to re-tessellate an editmode bmesh. - * add deform vert custom-data access. - + * add api for calling BMesh operators (unrelated to bpy.ops) + * add custom-data manipulation functions add/remove/rename. Example Script -------------- @@ -110,8 +109,8 @@ Here are some examples ... shape_lay = bm.verts.layers.shape["Key.001"] for vert in bm.verts: - shape = vert[shape_lay] - print("Vert Shape: %f, %f, %f" % (shape.x, shape.y, shape.z)) + shape = vert[shape_lay] + print("Vert Shape: %f, %f, %f" % (shape.x, shape.y, shape.z)) .. code-block:: python @@ -125,7 +124,7 @@ Here are some examples ... for vert in bm.verts: dvert = vert[dvert_lay] - + if group_index in dvert: print("Weight %f" % dvert[group_index]) else: diff --git a/doc/python_api/rst/info_gotcha.rst b/doc/python_api/rst/info_gotcha.rst index 25ef5175976..eb312799b41 100644 --- a/doc/python_api/rst/info_gotcha.rst +++ b/doc/python_api/rst/info_gotcha.rst @@ -132,6 +132,8 @@ write useful tools in python which are also fast to execute while in edit-mode. For the time being this limitation just has to be worked around but we're aware its frustrating needs to be addressed. +.. _info_gotcha_mesh_faces: + NGons and Tessellation Faces ============================ diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 8dd2a34932e..5408c479b7c 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -230,10 +230,10 @@ if not ARGS.partial: else: # can manually edit this too: - FILTER_BPY_OPS = ("import.scene", ) # allow - FILTER_BPY_TYPES = ("bpy_struct", "Operator", "ID") # allow + #FILTER_BPY_OPS = ("import.scene", ) # allow + #FILTER_BPY_TYPES = ("bpy_struct", "Operator", "ID") # allow EXCLUDE_INFO_DOCS = True - EXCLUDE_MODULES = ( + EXCLUDE_MODULES = [ "aud", "bge", "bge.constraints", @@ -262,7 +262,7 @@ else: "mathutils.geometry", "mathutils.noise", "Freestyle", - ) + ] # ------ # Filter @@ -270,7 +270,18 @@ else: # TODO, support bpy.ops and bpy.types filtering import fnmatch m = None - EXCLUDE_MODULES = tuple([m for m in EXCLUDE_MODULES if not fnmatch.fnmatchcase(m, ARGS.partial)]) + EXCLUDE_MODULES = [m for m in EXCLUDE_MODULES if not fnmatch.fnmatchcase(m, ARGS.partial)] + + # special support for bpy.types.XXX + FILTER_BPY_OPS = tuple([m[8:] for m in ARGS.partial.split(":") if m.startswith("bpy.ops.")]) + if FILTER_BPY_OPS: + EXCLUDE_MODULES.remove("bpy.ops") + + FILTER_BPY_TYPES = tuple([m[10:] for m in ARGS.partial.split(":") if m.startswith("bpy.types.")]) + if FILTER_BPY_TYPES: + EXCLUDE_MODULES.remove("bpy.types") + + print(FILTER_BPY_TYPES) EXCLUDE_INFO_DOCS = (not fnmatch.fnmatchcase("info", ARGS.partial)) |