[Bf-python] Suggestions for the basics of an NLA API

Toni Alatalo antont at kyperjokki.fi
Fri May 12 19:00:29 CEST 2006


Roland Hess wrote:

some first reactions, after a long work day and week and not being able 
to think much it seems:

> Armature.NLA would contain new methods to retrieve Action Strip objects:
>
> NLA.getActionStrips()
> Returns a list of all Action Strips associated with the Armature, in  
> the format {name, object}.
>
> NLA.getActionStrip("name")
> Returns the Action Strip object associated with "name" parameter.

in normal python i think these would be:
NLA.actionstrips #a dict/mapping type of actions strips
NLA.actionstrips.values() #the list of ActionObjects there
NLA.actionsstrips['name'] #gets an actionstrip by name
NLA.actionstrips.items() #list in format (name, object)

like you know this:

 >>> {'a': 1, 'b':2}.keys()
['a', 'b']
 >>> {'a': 1, 'b':2}['a']
1
 >>> {'a': 1, 'b':2}.items()
[('a', 1), ('b', 2)]

I will leave it for the group to decide what that means for the Blender API.

> ActionStrip.delete()
> Removes that Action Strip from the Armature's NLA list.

usually in Python lists are manipulated by manipulating lists, not list 
items:

 >>> list = ['a', 3, 'b', 2, 'c']
 >>> list.remove(2)
 >>> list
['a', 3, 'b', 'c']

 i am not sure if it could work nicely with the dict like thing 
mentioned above.

then again thinking how NLA GUI works in Blender, there of course strips 
are deleted by pointing the strip .. but i dont know what that means for 
scripting API desing. now i think that it and other reasons mean that 
your proposal is good .. or well dont know really.

> ActionStrip.moveUp()
> Moves the Action Strip up in the Armature's NLA List.

perhaps same problematics,
perhaps good for same reasons.

> ActionStrip.resetActionLimits()
> ActionStrip.resetStripSize()
> ActionStrip.snapToFrame()

these seem unproblematic to me, exactly what methods are for - telling 
the object to do something.

> ActionStrip.addStrip("Name",Action Object 

this i either misunderstand or find very strange.

you don't usually create new objects by referring to an existing similar 
one. i dont expect this to work:
 >>> i = 1
 >>> j = i.addInt(2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'int' object has no attribute 'addInt'

:)

> This function creates a new Action Strip, attached to the Armature  
> object. The strip would be created at the end of the linked list of  
> bActionStrips on object->nlastrips. The new Action Strip would have  the 

this perhaps give hints to us about how the creation should happen.

> Properties

saw no problem there (apart from the naming convention perhaps .. 
usually only classes, sometimes modules are with CamelCaps, and methods 
and properties, if capsed at all, iirc with smallStartingCamelCaps). i 
think even in bpy api only Modules, Module.Function()s and Classes are 
with initial capital, methods and attributeNames with not ( i may be 
missing something tho)

> Altering any of these properties or calling any of the methods  
> (except getStrips) should trigger an NLA window refresh.

this is problematic, 'cause we dont want a script that does a million 
things with strips, refresh windows a million times. on the other hand 
it may be difficult to ensure the refresh, if that is not done.

> Roland Hess

~Toni

p.s. great thanks for everyone active in this! perhaps the ED 
switchboard script (http://www.blender.org/~antont/makewireipos.py) can 
rewritten some day to create NLA strips instead of huge amount of keys 
in several places in respective ipos, and who knows what else this might 
be useful for (well, Roland / harkyman i guess also does know some uses 
already ;)



More information about the Bf-python mailing list