Posted: Sun Dec 15, 2002 11:34 pm
Joined: 10 Nov 2002
Posts: 30
I am trying to run the nice Python script located at:
http://www.blenderbuch.de/tutor/python1/python1_eng.html
At first, I had the problem of "whrandom" not being found, and then
after reading this group realized that I needed to intall Python,
which I did. Now, the script (Listing 1) goes successfully down to
"Const.BP_CURTIME" and then I get:
"There is no variable named Const"
Then, if I just make that
line "t = 0.0" just to see what comes next, I then get:
"AttributeError: Get:"
for this line in the code: lampdata = Lamp.Get("Lamp")
Any ideas? I am running Publisher 2.25 (unlocked with the
registration key) and Python 2.2 which is stored under
C:\Python22\Lib, which seems to be set correctly in Blender.
Posted: Sun Dec 15, 2002 11:48 pm
Joined: 16 Oct 2002
Posts: 1177
those scripts were written for a older version of the API. It might work in Blender 2.23, but not in 2.25.
Martin
_________________
Life is what happens to you when you're busy making other plans.
- John Lennon
Posted: Mon Dec 16, 2002 1:43 am
Joined: 10 Nov 2002
Posts: 30
Since the Python API has changed, apparently, is there
a Python file converter from 2.23 to Publisher (2.25)? I
looked around the net, and coudn't easily locate one, so
maybe it doesn't exist.
Posted: Mon Dec 16, 2002 8:31 pm
Joined: 16 Oct 2002
Posts: 1177
I don't think that kind of converter exists.
Martin
_________________
Life is what happens to you when you're busy making other plans.
- John Lennon
Posted: Sun Jul 27, 2003 11:28 pm
Joined: 03 Jun 2003
Posts: 127
I start learning Blender Python 2 days ago, hope it is not to late (if it not help you, maybe others).
I've changed a bit the code (pure luck, i gess) and it worked!
Here's the (tumble.py) for 2.25
# tumble.py by onk, 11.1999 (changed, of course)
import Blender
import math
from Blender import *
from math import *
import whrandom
# Number of frames for "once around" - the more
# frames, the slower the small lamp will tumble
speed = 100
pi2 = pi * 2
lamp = Object.Get("LampObj")
box = Object.Get("Box")
t = Blender.Get("curtime")
t = t - 1.0 # Begin with 0.0
# Allow the lamp to tumble about, also consider the size of the Box
# - try different sizes for the Box and then press Alt-A again
# the radius of the orbit should oscillate a little
r = box.SizeX* (0.7 + 0.1 * sin(10* t * pi2 /speed))
lamp.LocX = r * cos(t * pi2 / speed)
lamp.LocY = r * sin(t * pi2 / speed)
# Cause the lamp to flicker:
lampdata = Blender.Lamp.get("Lamp")
r = whrandom.random()
lampdata.Energ = 1.0 + 0.5 * r
# The Halo size should flicker likewise:
mat = Material.Get("Halo")
mat.HaSize = 0.10 * (1.0 + 0.5 * r)
Posted: Mon Jul 28, 2003 11:13 am
Joined: 03 Jun 2003
Posts: 127
Sorry, i've put the wrong /tumble.py)
Here's the Right one.
# tumble.py by onk, 11.1999
import Blender
import math
from Blender import *
from math import *
import whrandom
# Number of frames for "once around" - the more
# frames, the slower the small lamp will tumble
speed = 100
pi2 = pi * 2
lamp = Blender.Object.Get ("LampObj")
box = Blender.Object.Get ("Box")
t = Get ("curtime") # Begin with 0.0
t = t - 1.0
# Allow the lamp to tumble about, also consider the size of the Box
# - try different sizes for the Box and then press Alt-A again
# the radius of the orbit should oscillate a little
r = box.SizeX* (0.7 + 0.1 * sin(10* t * pi2 /speed))
lamp.LocX = r * cos(t * pi2 / speed)
lamp.LocY = r * sin(t * pi2 / speed)
# Cause the lamp to flicker:
lampdata = Blender.Lamp.Get ("Lamp")
r = whrandom.random()
lampdata.Energ = 1.0 + 0.5 * r
# The Halo size should flicker likewise:
mat = Material.Get("Halo")
mat.HaSize = 0.10 * (1.0 + 0.5 * r)