How to add a sound strip to a speaker from command line

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

barcodepandora
Posts: 6
Joined: Sat Sep 01, 2012 10:52 pm

How to add a sound strip to a speaker from command line

Postby barcodepandora » Tue Sep 04, 2012 5:40 am

Hello, I'm new in Blender. I'm creating animations with speakers. I wish to make a speakers plays its sound many times during an animation. I can do it from the Blender window. Now I want to do from a Python script from command line, but I could not.

I can do it with NLA editor; however, from command line I don't have access to a context with an area that let me do area.type = 'NLA_EDITOR'.

I can also from command line with NlaTrack[].strips.new() but I can't add a strip with sound.

¿How can I do more? ¿Can I obtain a context with area from command line? ¿Can I add a strip with sound from any context? Thank U very much :)

batFINGER
Posts: 33
Joined: Wed Jan 23, 2008 4:33 pm

Postby batFINGER » Wed Sep 19, 2012 4:50 pm

Hi

here is a sound clip added from the console. using the op and overriding the context, to make the NLA_EDITOR area context.area.

It adds a new track and clip for each active track.

Code: Select all

>>> C.object
bpy.data.objects['Speaker']

>>> C.screen.areas[5].type
'NLA_EDITOR'

>>> context = C.copy()
>>> context["area"] = C.screen.areas[5]
>>> bpy.ops.nla.soundclip_add(context)
{'FINISHED'}


Hopefully strips.new(name="xx", start=2, action=someaction) will have a parameter to set its type, which would make this a whole lot easier.

batFINGER
Posts: 33
Joined: Wed Jan 23, 2008 4:33 pm

Postby batFINGER » Wed Sep 19, 2012 6:11 pm

PPS on a closer look at your post I see you mention using command line. Don't think context override will work either.

BTW I've made some tools to make animating with speakers and sound a bit easier

http://blenderartists.org/forum/showthr ... r-Lipsync-)

My concept has always been to incorporate the NLA into this to have sound and action.

PS can you edit a post in this forum?


Return to “Python”

Who is online

Users browsing this forum: No registered users and 1 guest