Python "Const" attribute error

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

metaphorz
Posts: 30
Joined: Sun Nov 10, 2002 3:20 am

Python "Const" attribute error

Postby metaphorz » Sun Dec 15, 2002 11:34 pm

I am trying to run the nice Python script located at:

http://www.blenderbuch.de/tutor/python1 ... 1_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.

theeth
Posts: 1184
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Postby theeth » Sun Dec 15, 2002 11:48 pm

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

metaphorz
Posts: 30
Joined: Sun Nov 10, 2002 3:20 am

2.23 to 2.25 converter?

Postby metaphorz » Mon Dec 16, 2002 1:43 am

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.

theeth
Posts: 1184
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Postby theeth » Mon Dec 16, 2002 8:31 pm

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

madcello
Posts: 127
Joined: Tue Jun 03, 2003 10:51 pm

Postby madcello » Mon Jul 28, 2003 12:28 am

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)

madcello
Posts: 127
Joined: Tue Jun 03, 2003 10:51 pm

Postby madcello » Mon Jul 28, 2003 12:13 pm

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)


Return to “Python”

Who is online

Users browsing this forum: No registered users and 1 guest