Zweistein
(Zweistein)
September 12, 2003, 7:55am
1
Hi,
i want to try some basic Python scripting. I tried an example from the official Python API for Blender 2.28a:
from Blender import Camera, Object, Scene
c = Camera.New(‘ortho’). # create new ortho camera data
c.lens = 35.0 # set lens value
cur = Scene.getCurrent(). # get current scene
ob = Object.New(‘Camera’). # make camera object
ob.link©. # link camera data with this object
cur.link(ob). # link object into scene
cur.setCurrentCamera(ob). # make this camera the active";
It is on this address: http://www.blender.org/modules/documentation/228PythonDoc/Camera-module.html
But it does not work. I have Python 2.2.2 and Blender 2.28a.
It says:
c = Camera.New(‘ortho’). # create new ortho camera data
Invalid Syntax and Attribute error: unknown specified object.
btw: Are Plugins for Blender written in Python, too?
Ummm
There shouldn’t be any periods at the ends of the lines of code.
Try:
from Blender import Camera, Object, Scene
c = Camera.New(‘ortho’) # create new ortho camera data
c.lens = 35.0 # set lens value
cur = Scene.getCurrent() # get current scene
ob = Object.New(‘Camera’) # make camera object
ob.link© # link camera data with this object
cur.link(ob) # link object into scene
cur.setCurrentCamera(ob) # make this camera the active";
The Plug-in system uses the C programming language.
You can find out more at:
http://www-users.cs.umn.edu/~mein/blender/plugins/
roc
(roc)
September 15, 2003, 1:01pm
4
whew! this did work and has gotten me started with the Python - Blender combo. since i’ve programmed in other languages im sure that what i want to do is probably feasible here, but the first steps in new language are the hardest. Thank you!!
theeth
(theeth)
September 15, 2003, 3:02pm
5
when you post code, please use the
tags, it preserves tabs and spaces correctly and makes it obvious what is code and what is not.
Martin
stani
(stani)
September 15, 2003, 8:16pm
6
Try out the spe editor (unless you have Linux and you use the prebuilt binaries from blender.org ), see http://spe.pycs.net See Documentation>installation for getting it started.
Ciao,
Stani