Joining two cubes with a hinge using python in Blender render

Happy holidays to all

After years of using Blender using only the UI, I am now starting to learn Python. I have benefitted from many useful tutorials and forum posts but am stuck right now hoping someone can point me in the right direction.

For now, I would like a python script which will connect two cubes with a hinge constraint, while in Blender Render.

I am using 2.75a right now, and i want to do this within the Blender Render (not GE - I did see some examples like this for BE but they wont run in BR)

I can do this easily in the GUI but I want to do it algorithmically to many objects - hence the desire for a script. When I do it using the UI, the python window shows instructions like the ones below - but I can’t figure out how to insert those into the script and have them act on the objects I want them to act upon (let’s say those objects are Cube.01 and Cube.02, for example). I’m a Python newbie otherwise probably this would be easy.

bpy.ops.rigidbody.constraint_add()
bpy.ops.object.select_all(action=‘DESELECT’)
bpy.ops.rigidbody.connect(con_type=‘HINGE’)

thanks for any help, pointers, code snippets.

Matt

I figured it out - turns out it’s very easy:

bpy.data.objects[‘Cube’].select = True
bpy.data.objects[‘Cylinder’].select = True
bpy.ops.rigidbody.connect(con_type=‘FIXED’)

And this portion of the API reference was quite helpful:
http://www.blender.org/api/blender_python_api_2_76_2/bpy.ops.rigidbody.html

Matt