diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-08 04:13:19 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-08 04:13:19 +0300 |
commit | fac2ca1c7ca26b9e7019d5c3367b1cb758ba8ca4 (patch) | |
tree | 9f4b7e554ceee580d01fb22702d8b6ff01064bbf /release/scripts/op | |
parent | 30c4c4599dfb72b430a409648bb1407a0f197332 (diff) |
bpy/rna api class feature
- python defined classes will be used when available (otherwise automaically generated metaclasses are made as before)
- use properties rather then functions for python defined rna class's
- call the classes getattr AFTER doing an RNA lookup, avoids setting and clearing exceptions for most attribute lookups, tested UI scripts are ~25% faster.
- extending rna py classes this way is a nicer alternative to modifying the generated metaclasses in place.
Example class
--- snip
class Object(bpy.types.ID):
def _get_children(self):
return [child for child in bpy.data.objects if child.parent == self]
children = property(_get_children)
--- snip
The C initialization function looks in bpy_types.py for classes matching RNA structure names, using them when available.
This means all objects in python will be instances of these classes.
Python properties/funcs defined in ID py class will also be available for subclasses for eg. (Group Mesh etc)
Diffstat (limited to 'release/scripts/op')
-rw-r--r-- | release/scripts/op/mesh.py | 4 | ||||
-rw-r--r-- | release/scripts/op/mesh_skin.py | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/release/scripts/op/mesh.py b/release/scripts/op/mesh.py index 8ea9ea03062..f78e33730f0 100644 --- a/release/scripts/op/mesh.py +++ b/release/scripts/op/mesh.py @@ -28,9 +28,9 @@ def main(context): mesh = ob.data face_list = [face for face in mesh.faces] - face_edge_keys = [face.edge_keys() for face in face_list] + face_edge_keys = [face.edge_keys for face in face_list] - edge_face_count = mesh.edge_face_count_dict(face_edge_keys) + edge_face_count = mesh.edge_face_count_dict def test_interior(index): for key in face_edge_keys[index]: diff --git a/release/scripts/op/mesh_skin.py b/release/scripts/op/mesh_skin.py index 85df6463eb0..f9a92c8cd82 100644 --- a/release/scripts/op/mesh_skin.py +++ b/release/scripts/op/mesh_skin.py @@ -256,11 +256,11 @@ def getSelectedEdges(context, me, ob): if MESH_MODE == 'FACE': context.scene.tool_settings.mesh_selection_mode = 'EDGE' # value is [edge, face_sel_user_in] - edge_dict= dict((ed.key(), [ed, 0]) for ed in me.edges) + edge_dict= dict((ed.key, [ed, 0]) for ed in me.edges) for f in me.faces: if f.selected: - for edkey in f.edge_keys(): + for edkey in f.edge_keys: edge_dict[edkey][1] += 1 context.scene.tool_settings.mesh_selection_mode = MESH_MODE @@ -280,7 +280,7 @@ def getVertLoops(selEdges, me): vert_used = [False] * tot for ed in selEdges: - i1, i2 = ed.key() + i1, i2 = ed.key vert_siblings[i1].append(i2) vert_siblings[i2].append(i1) |