Blender Python nulls along a curve

I’ve been trying  to learn python in blender and here’s my first go at scripting something:

To use:

1.make a nurbs curve

2.make 5 nulls/empties

3.select all empties

4.run script


import bpy

selected = bpy.context.selected_objects

count = 0
total = 4
offset = 0.0

for obj in selected:
offset = count/total
bpy.context.scene.objects.active = obj
bpy.ops.object.constraint_add(type='FOLLOW_PATH')
bpy.context.object.constraints["Follow Path"].target = bpy.data.objects["NurbsPath"]
bpy.context.object.constraints["Follow Path"].use_fixed_location = True
bpy.ops.object.location_clear()
bpy.context.object.constraints["Follow Path"].offset_factor = offset
count += 1

curveRigging_01

eyelidSetup

Hoping to make it more generic and dynamic and as a operator.

I tried getting the list.count for the total but it wasn’t returning a decimal number :S so need to find out how to get the count of a selection. list.count()

Also want to make it so that the last object selected is the curve, at the moment it just looks for a curve called NurbsCurve, LAME.

I think it’s a good start for learning python and it’s loads of fun, I’m looking forward to rigging more things with curves.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s