Report problems with the new Python API here please!

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

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

Post by theeth » Thu Jul 03, 2003 6:12 am

would be nice if the objects returned by the Effect module had a Refresh function of some sort.

Martin
Life is what happens to you when you're busy making other plans.
- John Lennon

willian
Posts: 0
Joined: Mon Jan 13, 2003 3:50 am

Post by willian » Thu Jul 03, 2003 8:20 am

t_revs wrote:Can't seem to get name in PutRaw to return anything except None
Hi, this is fixed in cvs now, thanks for reporting. PutRaw will return the object when one had to be created or None when the object already existed, as in 2.25. Besides that, the 'name' field (mesh name) can now be changed.

Willian

sumedho
Posts: 0
Joined: Sat May 03, 2003 6:21 am

Post by sumedho » Thu Jul 03, 2003 8:58 am

OS: osx 10.2.5
Python: python 2.2.3

Problem:

When starting blender the following error:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
no font found for international support
Using a clean Global Dictionary.
Run Python script "Text" ...

Printing sys.path gives:

['/usr/local/lib/python2.2', '/sw/lib/python2.2/', '/sw/lib/python2.2/plat-darwin', '/sw/lib/python2.2/lib-tk', '/sw/lib/lib-dynload', '/Users/sumedho/blender/blender.app/Contents/MacOS/', '', '']

Works fine on tuopoh and blender2.27. Normally the sys.path is
/usr/local/lib/python2.2 but for some reason this version of blender appends /sw/lib/python2.2/ instead. Setting PYTHONHOME enables some features working but causes problems in normal python operation.

jgreen
Posts: 0
Joined: Thu Jul 03, 2003 4:24 pm

Crash with Blender 2.27 NewPy1

Post by jgreen » Thu Jul 03, 2003 4:31 pm

Not sure if you were also interested in general non-python related problems with the pre-release of blender, but.. I get a crash on Linux with either the static or dynamic versions of the pre-release. I did not have this problem with 2.27. Here is a gdb back trace for the static blender binary:
Program terminated with signal 4, Illegal instruction.
#0 0x082d2f76 in png_handle_gAMA ()
#1 0x082c4031 in png_read_info ()
#2 0x0828d759 in imb_png_decode ()
#3 0x08284890 in IMB_ibImageFromMemory ()
#4 0x080d4859 in BIF_resources_init ()
#5 0x080e7965 in BIF_write_autosave ()
#6 0x080e7a08 in BIF_init ()
#7 0x0809c0df in main ()

Bischofftep
Posts: 0
Joined: Thu Feb 06, 2003 11:01 pm
Location: Richmond, VA
Contact:

Quick Issues

Post by Bischofftep » Thu Jul 03, 2003 8:04 pm

Heyo:

Some quick issues from OS X build from CVS as of 7-3-03 am:

----
Traceback (most recent call last):
File "lanc_povanim226_14h.p", line 1670, in draw4
File "povanim226_14h.py", line 4004, in draw_buttons
File "povanim226_14h.py", line 2408, in gettext
AttributeError: 'str' object has no attribute 'name'
----
exporttoyafray
focale = cam.Lens / (aspect * 32.0)

AttributeError: Lens
----
There doesn't seem to be any support for accessing lights yet?

YABLE does not return any info on any selected lights.

Otherwise excellent continued work everyone!!

-Bischofftep

jms
Posts: 33
Joined: Sat Oct 19, 2002 3:04 pm

Post by jms » Fri Jul 04, 2003 4:37 pm

Now povanim works with Blender2.27-new-py
but little changes are needed:

Code: Select all

def matrix2sizrotloc(mat0,O):
                    from math import cos, sin, acos, asin, atan2, atan
                    global B228
                    if not B228: 
                        LocX = mat0[3][0]
                        LocY = mat0[3][1]
                        LocZ = mat0[3][2]
                        ....
                        return(LocX, LocY, LocZ, \
                                RotX, RotY, RotZ, \
                                SizeX, SizeY, SizeZ)
                     
                    elif B228==1 and O!=None:
                        return(O.LocX,O.LocY, O.LocZ, \
                                O.RotX, O.RotY, O.RotZ, \
                                O.SizeX,O.SizeY , O.SizeZ)

Code: Select all

if not funblender and not B228:
     mode=sLmat.mode
     mirG=sLmat.mirG
     mirB=sLmat.mirB
     mirR=sLmat.mirB
elif funblender:
     mode=sLmat.Mode
     mirG=sLmat.MirG
     mirB=sLmat.MirB
     mirR=sLmat.MirR
elif B228:      
     mode=sLmat.mode
     mirG=sLmat.mirCol[0]
     mirB=sLmat.mirCol[1]
     mirR=sLmat.mirCol[2]
Zoo-3D.Blender, Ze French-Speaking Community SKB My french book about Blender.

jms
Posts: 33
Joined: Sat Oct 19, 2002 3:04 pm

Re: Report problems with the new Python API here please!

Post by jms » Fri Jul 04, 2003 5:27 pm

jms wrote: in module BLender.Object

Code: Select all

import Blender
OBJLIST=Blender.Object.Get()
for o in OBJLIST:
     print o.name,o.Layer,
return this:

Using a clean Global Dictionary.
Run Python script "Text" ...
Traceback (most recent call last):
File "Text", line 4, in ?
AttributeError: 'str' object has no attribute 'name'
Same problem with Blender.Image.Get().
Zoo-3D.Blender, Ze French-Speaking Community SKB My french book about Blender.

jms
Posts: 33
Joined: Sat Oct 19, 2002 3:04 pm

Post by jms » Fri Jul 04, 2003 7:05 pm

:(

Code: Select all

import Blender
me=Blender.NMesh.GetRaw('Plane')
print me.materials
Crash

Code: Select all

import Blender
me=Blender.NMesh.GetRaw('Plane')
print str(me.materials)
no problem.
Zoo-3D.Blender, Ze French-Speaking Community SKB My french book about Blender.

jms
Posts: 33
Joined: Sat Oct 19, 2002 3:04 pm

Post by jms » Fri Jul 04, 2003 7:44 pm

In edit button window.
TextFace and VertCol can be used together
if the mesh is "vertex painted" after it was
"faceseleted"

But button VertCol remains on Make and
no signal is given to the python.

VertCol alone works correctely.
Zoo-3D.Blender, Ze French-Speaking Community SKB My french book about Blender.

jms
Posts: 33
Joined: Sat Oct 19, 2002 3:04 pm

Post by jms » Fri Jul 04, 2003 9:03 pm

http://jmsoler.free.fr/util/blenderfile ... 228_01.zip

This temporary version of the povanim script is the result of all my remarks upon B2.27_new.py
Zoo-3D.Blender, Ze French-Speaking Community SKB My french book about Blender.

Anthony
Posts: 7
Joined: Fri Oct 25, 2002 5:14 am

GetSelected() vs Get()

Post by Anthony » Sun Jul 06, 2003 1:07 am

GetSelected() vs Get()

I'm updating my IO Suite for 2.27.New-Py1 and stumbled on this strange behavior:

Blender.Object.GetSelected(): returns <type 'Blender Object'>
Blender.Object.Get(): returns <type 'str'>

Shouldn't Get() return Blender Objects as well?

xand
Posts: 33
Joined: Wed Oct 16, 2002 9:46 am

Post by xand » Sun Jul 06, 2003 6:02 pm

my script in this blend http://www.zoo-logique.org/3D.Blender/b ... axis.blend crashes blender.
it works fine in 2.27. it seems relatred to matrix manipulation

code :

Code: Select all

#Realign Script
#
#Aout 2001
#Xand@wanadoo.fr
#
#Choisir la source puis la cible, appuyer sur Alt+P, les axes de cible sont alignés sur ceux de source mais le mesh ne bouge pas.
#l'échelle ne joue pas
#
#
#Select Source then Cible, press Alt+p, Cible's axis are realigned with Source's axis but the mesh don't move.
#The rotation is size free
#
#Free for use with Blender
#



from Blender import Object, NMesh, Redraw
import vect
#pourquoi toujours réinventer la roue, en plus ça clarifie le script
from math import *

def applyTransform(mesh,mat):
	for v in mesh.verts:
		#applique la transformation à chaque vertex
		vec = (v.co[0], v.co[1], v.co[2])
		vec = vect.matxvec(mat,vec)
		v.co[0], v.co[1], v.co[2] = vec[0], vec[1], vec[2]

def matrot(ob):
	# récupère la matrice de rotation
	vx=ob.mat[0]
	vy=ob.mat[1]
	vz=ob.mat[2]
	#normalise la matrice par rapport aux paramètres size
	isizex=1/ob.size[0]
	isizey=1/ob.size[1]
	isizez=1/ob.size[2]
	matx=vect.scale3(isizex,vx)
	maty=vect.scale3(isizey,vy)
	matz=vect.scale3(isizey,vz)
	mat=(matx,maty,matz)
	return mat




oblist =Object.GetSelected()
lenob=len(oblist)

if lenob !=2:
	#envoie un message d'erreur si 2 objets ne sont pas sélectionnés
	raise ValueError,'Select 2 objects'

cible=oblist[0]
source=oblist[1]


if source.rot!=cible.rot:
	#pour éviter de faire tourner les vertices si le script est appliqué plusieurs fois
	#calcul de la matrice de passage
	#en fait, on fait tourner les vertices dans l'autre sens et on ramène dans l'axe tout l'objet
	rotcible=matrot(cible)
	rotsource=matrot(source)
	rotsourcet = vect.invmat(rotsource)
	mat=vect.matxmat(rotcible,rotsourcet)
	#récupère les datas et applique la transformation aux vertices
	ncible=cible.name
	me=NMesh.GetRaw(ncible)
	applyTransform(me,mat)
	NMesh.PutRaw(me,ncible)
	#réaligne les axes
	cible.rot=source.rot
the vect module is the one from Martin Strubel

+++

FouKevin
Posts: 0
Joined: Fri May 16, 2003 11:14 am

No more layer attribute for objects ?

Post by FouKevin » Wed Jul 09, 2003 10:30 am

I used to use the layer attribute of objects for exporting purpose.
But it seems this attribute has disappeared from the new Python API.

objList = Object.GetSelected()
for o in objList:
print o.name, o.layer

reports me an AttributeError: layer

Is there another way to get the layer of an object ? will it be reimplemented ?

Thank you a lot.
Thanks for making Blender.

FouKevin
Posts: 0
Joined: Fri May 16, 2003 11:14 am

Vertex Influences

Post by FouKevin » Wed Jul 09, 2003 12:40 pm

Trying to get information about Vertex Influences through python
Using this code :

Code: Select all

...
m = NMesh.GetRaw(o.name)
for v in range(len(m.verts)):
    vi = m.getVertexInfluences(v)
    print vi
Works fine.
But when a vertex is assigned to 2 different groups, I get a Segmentation Fault.

Thank you !

Money_YaY!
Posts: 442
Joined: Wed Oct 23, 2002 2:47 pm

Post by Money_YaY! » Mon Jul 14, 2003 5:06 pm

ok from my side.
Have no clue where python log is. And no clue of version. (installed from source took 6 hours, not doing that again)

But ! I am happy to report that alt-p brings GUI's back .
Tried Make human, yafray, and head make. None however did anything
after that. Gui sliders and buttons work, just nothing happens. And it just goes back to the script when the task is done.

osx 10.2.4

^v^ find it.

Locked