(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


But this alone won't work.

sorry I'm a newbie to blender.


1 Answer 1


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


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .