Hi all, i’m really new to Blender and python so excuse me if my question seems so noob
I’d like to create an auto path (poly) from still camera positions that will be then constrainted to a object. I red a lot from the Blender’s wiki to get functions but i’m missing something and some help will be really appreciated. Here’s my first script i wrote. And of course i doesn’t work But i don’t understant why. Included a snapshot of my pb.
You must paste your code with the advanced button “GO ADVANCED” and use # button, please!
If not I can’t use your script because the indentation disappear!
Hi Spirou, thanks for getting back to me. I work a bit more and detected a pb whith the coords format i was using. I almost managed to get what i’d like to get, but still meeting some difficulties with the locations. I’d like to make start poly at first cam location towards the cam + 1 location. Here is what i’ve done, but still looking how to handle the cams.loc +1 :
import bpy
from mathutils import Vector
select scene
scene = bpy.context.scene
w = 0.2 # weight
number of cameras in scene
ob_list = bpy.data.cameras.items()
total_cams = len(ob_list)
print (“total number of cams:”, total_cams) # check
for objcams in scene.objects:
if objcams.type == ‘CAMERA’:
bpy.context.scene.camera = objcams
x, y, z = objcams.location
# print (x, y, z) # check
i = int(i + 1) #print (i) # check
# Poly
# link to scene
objectdata = bpy.data.objects.new(“ObjCurve”, curvedata)
objectdata.location = (x, y, z) #object origin is current cam
bpy.context.scene.objects.link(objectdata)
# add & draw
polyline = curvedata.splines.new(‘POLY’) #print (i - 1)
polyline.points.add(i)
polyline.points[i].co = (x, y, z, w)
Pierre tu ne comprends pas ce que je te demande:
Colle ton code python avec le bouton “code” -> # en écrivant ton message avec le bouton “GO ADVANCED”, stp
car il n’y a plus les indentation dans ce que tu fais actuellement, stp!!! Ton message est inutile!
import bpy
from mathutils import Vector
# select scene
scene = bpy.context.scene
w = 0.2 # weight
# number of cameras in scene
ob_list = bpy.data.cameras.items()
total_cams = len(ob_list)
print ("total number of cams:", total_cams) # check
# Poly
# type of curve
curvedata = bpy.data.curves.new(name='Curve', type='CURVE')
curvedata.dimensions = '3D'
# set origin of future curve to first cam location
origin = bpy.data.objects['Viewpoint.001'].location
# first cam item number
i = total_cams / total_cams
# ob_cam_list_position
for objcams in scene.objects:
if objcams.type == 'CAMERA':
bpy.context.scene.camera = objcams
x, y, z = objcams.location
# print (x, y, z) # check
i = int(i + 1)
#print (i) # check
# Poly
# link to scene
objectdata = bpy.data.objects.new("ObjCurve", curvedata)
objectdata.location = (x, y, z) #object origin is current cam
bpy.context.scene.objects.link(objectdata)
# add & draw
polyline = curvedata.splines.new('POLY')
#print (i - 1)
polyline.points.add(i)
polyline.points[i].co = (x, y, z, w)