2
$\begingroup$

(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.

$\endgroup$
2
$\begingroup$

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)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.