BlenderDev/BpyApiDiscussion

Wikipedia,自由的百科全书

Contents

Blender Python API Discussion

This page is for discussion of Bpy design issues, future directions, work-in-progress, and general ranting.


Discussion for the new Blender python API...

BPy API Cleanup - 2006



The TODO List

Ongoing Work

Design & Discussion of the API

Ideasmans comments on object/scene context

What I'd like to see changed in the new API is the way blender handles user contexts.

Having Blender.Object.Get() and Blender.Object.GetSelected() in the same module is ok, but they do very different things and this isn't really understood by many python coders.

GetSelected - Gets all the objects in the current scene that are selected and on visible layers.

Where as Object.Get() gets all objects from all scenes, in most cases Object.Get() should be replaced by scn.getChildren() (current function).

Even if we keep this I'd like to make it easier for people to work with the scene.


Here are some things that could be changed in the scene module.

scn - Where scn could be Blender.Scene.GetCurrent()

  • scn.getChildren() -> scn.objects (iterator) - Children isnt the best metaphore, since objects can exist in multiple scenes- therefor having multiple parents.
  • scn.link(ob) -> scn.objects.append(ob), or scn.objects.extent([ob, ...])
  • scn.unlink(ob) -> scn.objects.remove(ob)
  • scn.getActiveObject() -> scn.activeObject
  • ob.sel=1 (to set the active object) -> scn.activeObject = ob
  • Object.GetSelected() -> scn.objectContext (iterator)

Using iterators also works nicely with blenders internal data structure because we can just keep returning the next item in the linked list. - saving memory by avoiding generating large lists.

--ideasman

Submitting Patches

Future Directions

Group support!

Groups could be an object Basicaly with a name and a list of objects.

each object has a group property- None when not a part of a group. Also for group parents (DupliGroups) - we need 2 properties. ob.dupliGroup = someGroup ob.dupliGroupEnable = True/False

so for an object to find its group...

if ob.group != None: groupOb = [ o for o in ob.group.objects.iteritems() ] else: groupOb = []

General Comments/Rants

Personal tools