Any hints on how to add a Camera?

Can anyone point me in the right direction here?

The following stab in the dark definatley does not work…


	sc = Scene.getCurrent()
	GCam=Camera.New()
	OCam=Object.New('Camera')
	OCam.link(GCam)
	OCam.setLocation([x1,y1,z1])
	sc.link(OCam)


Any hint on setting the camera’s Look_at direction would be appreciated, too.

Many thanks,

Rink

try this, it will get the camera and move it, might help you.

import Blender
from Blender import Object
cam = Blender.Object.Get("Camera")
cam.LocX = cam.LocX + 5
Blender.Redraw()

Thanks for the reply.

Unfortunatly that will only get the camera (if it exists in the scene). I want to add more cameras and place them in the scene looking at different items.

Rink


import Blender
from  Blender import Camera,Scene,Object

sc = Scene.getCurrent()
GCam=Camera.New()
OCam=Object.New('Camera')
OCam.link(GCam)

OCam.RotX=1.57  #this is the real "Look At" function

sc.link(OCam)
Blender.Redraw()

x1=2.0
y1=2.0
z1=0.0

OCam.LocX=x1
OCam.LocY=y1
OCam.LocZ=z1

Blender.Redraw()

Tested on blender 2.28 , works perfectly.

JMS,

Cannot get the code you specified to work in 2.27 (2.28 might work for all I know, but it kills my script).

Bit of a Bummer.

Rink

Just tested, it works perfectely in b2.27 too.

Just an advise:
do not import the script in the blender text window with the short cut ctrl-shift-V, this adds a very very bad character at the end of each line.

JMS,

This is my code (cut and pasted from PythonWin rather than the other way around :wink: )


	sc = Scene.getCurrent() 
	GCam=Camera.New()
	OCam=Object.New('Camera')
	OCam.link(GCam)
	OCam.RotX=anglet 
	sc.link(OCam)
	OCam.LocX=x1 
	OCam.LocY=y1 
	OCam.LocZ=z1
	Blender.Redraw() 

Still can’t get it to work. Can’t think of a reason.

Thanks for your efforts.

Rink

What is the text error in the console?

No Error reported.

No cameras drawn.

Try to find if there is (or not) a new object camera with shift-F4
short cut…

Well, I’m blowed!

4 little cameras! Just little dots, though,