4

(suppose camera is in the right location already)

I understand if doing this manually I need to select the camera and hold shift and select the curve that I want to follow, then ctrl+p and select "follow path". But how do I make this with python script?

My guess is I can use python script to implement these tow steps in order. It seems that "Follow path" can be achieved by

bpy.ops.object.parent_set(type='FOLLOW')

But this alone won't work.

sorry I'm a newbie to blender.

diodeBucks
  • 173
  • 1
  • 8

1 Answers1

5

Thanks for @poor 's comment. It can be done in the way of

make object A a parent of object B via Python

specifically, it needs to be coded like:

camera = bpy.data.objects['Camera']
path = bpy.data.objects['NurbsPath']
lamp = bpy.data.objects['Lamp']

camera.select = True
lamp.select = True
path.select = True

bpy.context.scene.objects.active = path #parent

bpy.ops.object.parent_set(type='FOLLOW') #follow path

you can find the objects name in python console with

list(bpy.data.objects)
diodeBucks
  • 173
  • 1
  • 8