Report problems with the new Python API here please!

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

ideasman
Posts: 0
Joined: Tue Feb 25, 2003 2:37 pm

Adding materials to a mesh, not working in 2.27 or 2.27pre

Post by ideasman » Tue Jul 15, 2003 7:19 am

This code below is from the 2.25 docs.

I get the error
AttributeError: addMaterial

I have tried many things and posted a question on www.elysiun.com

Is there a new command?
At the moment there is no way to add a material to a mesh.
in 2.27 or 2.28pre

Code: Select all

 from Blender import Material, NMesh, Object, Scene
    m = Material.New()                         # create free Material datablock
    m.rgbCol = (1.0, 0.0, 0.3)                    # assign RGB values
    mesh = NMesh.GetRaw()                      # get new mesh
    mesh.addMaterial(m)                        # add material to mesh
    object = Object.New('Mesh')                # create new object 
    object.link(mesh)                          # link mesh data to object
    Scene.getCurrent().link(ob)                # link object to current scene



[/code]

pat
Posts: 21
Joined: Mon Nov 18, 2002 3:51 pm
Location: germany

other scripts

Post by pat » Tue Jul 15, 2003 9:48 am

what about importing other scripts like
import testscript
or
from testscript import testfunction
where testscript is testscript.py in the .blend

i couldn't find a way to get this working (for the fiber13-script on elysiun)
someone please tell me if this is a bug or just my foolness :wink:

oops, same problem as T&N on page 1

Qbertino
Posts: 11
Joined: Sun May 11, 2003 2:31 am

Static Linux Version of 2.27-newpy complains:

Post by Qbertino » Tue Jul 15, 2003 10:51 pm

error while loading shared libraries: libstdc++.so.5: cannot load shared object file: No such file or directory

and, after installing that

error while loading shared libraries: libgcc_s.so.1: cannot load shared object file: No such file or directory

I thought 'static' ment 'batteries included' or ... you no what I mean.
Wrong?
A Gimp/PS debate is pointless. A Blender/LW debate is interesting.

Qbertino
Posts: 11
Joined: Sun May 11, 2003 2:31 am

lib Problems continued:

Post by Qbertino » Tue Jul 15, 2003 11:09 pm

lib Problems continued:

Won't start, no matter what I install.

See this:
./blender: /usr/lib/libstdc++.so.5: version `GLIBCPP_3.2.2' not found (required by ./blender)
./blender: /lib/libc.so.6: version `GLIBC_2.2.3' not found (required by ./blender)
./blender: /lib/libc.so.6: version `GLIBC_2.3' not found (required by ./blender)
./blender: /lib/libpthread.so.0: version `GLIBC_2.3.2' not found (required by ./blender)

The new Blender seems to be extremely picky about the different libs and their each version. 3 (!!) different glibc's??? Is that true? Isn't that a little much? Or am I getting it all wrong?

Any suggestions?
A Gimp/PS debate is pointless. A Blender/LW debate is interesting.

ideasman
Posts: 0
Joined: Tue Feb 25, 2003 2:37 pm

Re: Adding materials to a mesh, not working in 2.27 or 2.27p

Post by ideasman » Wed Jul 16, 2003 12:42 pm

There is no problem.

Its just not documented in the NMesh 2.25 docs.



This should work:
#------------------------------------------------
import Blender
from Blender import Material, NMesh
m = material.New("newmat")
m.rgbCol = (1.0, 0.0, 0.3)
me = NMesh.GetRaw("Plane") # considering the default plane
me.materials.append(m) # here is the way to assign materials in NMesh

# now to put this mesh on a new object:

newme = NMesh.PutRaw(me, "newPlane")

# or to simply update the "Plane" mesh, comment the line
above and
# uncomment this one:

# me.update()
#-------------------------------------------------

Any problem, feel free to email me or the bf-python list (where you
need
to be a member to be able to send emails):
http://www.blender.org/mailman/listinfo/bf-python

ideasman wrote:This code below is from the 2.25 docs.

I get the error
AttributeError: addMaterial

I have tried many things and posted a question on www.elysiun.com

Is there a new command?
At the moment there is no way to add a material to a mesh.
in 2.27 or 2.28pre

Code: Select all

 from Blender import Material, NMesh, Object, Scene
    m = Material.New()                         # create free Material datablock
    m.rgbCol = (1.0, 0.0, 0.3)                    # assign RGB values
    mesh = NMesh.GetRaw()                      # get new mesh
    mesh.addMaterial(m)                        # add material to mesh
    object = Object.New('Mesh')                # create new object 
    object.link(mesh)                          # link mesh data to object
    Scene.getCurrent().link(ob)                # link object to current scene



[/code]

Michel
Posts: 180
Joined: Wed Oct 16, 2002 7:27 pm
Location: Somewhere below the rivers in Holland (but not Limburg)

Re: Static Linux Version of 2.27-newpy complains:

Post by Michel » Wed Jul 16, 2003 10:47 pm

Qbertino wrote:error while loading shared libraries: libstdc++.so.5: cannot load shared object file: No such file or directory

and, after installing that

error while loading shared libraries: libgcc_s.so.1: cannot load shared object file: No such file or directory

I thought 'static' ment 'batteries included' or ... you no what I mean.
Wrong?
My glibc and gcc versions are too 'new' :lol:
For the next pre-release and ultimately the 2.28 release, I'll use another build system to build Linux binaries.

With regards,
Michel

noselasd
Posts: 12
Joined: Wed Oct 16, 2002 12:08 pm

Post by noselasd » Tue Aug 05, 2003 3:10 pm

basse wrote:this is perhaps not really a bug report for the new API, but in any case, this is what I got trying to run it:
./blender: /usr/lib/libstdc++.so.5: version `GLIBCPP_3.2.2' not found (required by ./blender)

system: redhat 8.0


.b
This means blender was compiled on a system with gcc 3.2.2 (and a gcc 3.2.2 compiled libstdc++).
Use the binary from blender.org or compile your own.

effeuno
Posts: 4
Joined: Thu Oct 17, 2002 11:58 pm
Location: Piacenza (IT)

About Object.setLocation and Ipo.setCurveBeztriple

Post by effeuno » Fri Aug 08, 2003 12:23 pm

Hi, I think I've found a bug in Object module; here the simpliest code about it:

Code: Select all

import Blender

obj = Blender.Object.Get("Plane")
obj.setLocation(1.0, 1.0, 1.0)
And here the error message:

Code: Select all

Traceback (most recent call last):
  File "Text", line 4, in ?
AttributeError: expected three float arguments
I've found it on both OSX and Win2k (blender version is 228).

About method setCurveBeztriple by Ipo module I think it is bugged too: it places the point indicated by the first two params in a fixed point (coords -0.9990, -1.0) without considering the Bez control point supplied.
However I know you know the module is far from be complete.

That's all, bye
F1

LukeW
Posts: 0
Joined: Mon Mar 03, 2003 1:14 pm

Post by LukeW » Sun Aug 10, 2003 2:23 pm

This works:

Code: Select all

import Blender

selectionList = Blender.Object.GetSelected()

for i in range(5):
  print i
If GetSelected() is replaced with getSelected(), it does the loop, then halts with this error:
Traceback (most recent call last):
File "Text", line 5, in ?
File "C:\PYTHON22\Lib\warnings.py", line 38, in warn
filename = sys.argv[0]
AttributeError: 'module' object has no attribute 'argv'
It halts - if there is code after the loop, that code isn't run. If it is a nested loop, the inner loop is run once.

If "getSelected()" is still there and "range" is replaced with "xrange" it works again.

I thought depreciated functions would act the same as non-depreciated functions... (it's a bug I guess)
e.g. something like:
function getSelected()
print warning
return GetSelected()

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

Post by theeth » Sun Aug 10, 2003 4:57 pm

that bug is fixed in 2.28a.

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

assassin
Posts: 0
Joined: Sat Aug 09, 2003 12:47 pm

rotation

Post by assassin » Sun Aug 10, 2003 6:07 pm

Hi . I am not sure if this is a bug but when I try to get the data
after the rotation and I put the data into a file
then I have a file with coordinates vectors but everything
is without rotation,

So I tryed to use getDeformedData cause it sounded like something
with I can get rotated verteces. But I won't work.

But if not . I would still wanna know ho to put the rotated object into
a file.

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

Post by theeth » Sun Aug 10, 2003 6:15 pm

apply the deformation matrix to the vertice coordinates.

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

ascotan
Posts: 0
Joined: Thu May 29, 2003 10:32 pm
Location: Maryland, U.S.

Post by ascotan » Wed Aug 13, 2003 2:08 am

Blender 2.28 release that I downloaded crashes when I try to link mesh data to a blender object. I thought that mabe the API changed, etc. because of the new blender interface. However my script runs perfectly on my own build of the debug and the release of the current cvs checkout. I don't understand what is different about the 2.28 release???

The problem occurs when the link ob.link(me) is executed.

Code: Select all

ob = Object.New('Mesh', md3obj.surfaces[i].name)
ob.link(me)
sc = Scene.getCurrent()
sc.link(ob)
matrix = ob.getMatrix()
print matrix
Blender give an access violation and crashes on windows xp/2000.
The current checkout seems different then the release though...

oops. The 2.28a release fixes it. The normal download from blender3d.org though is still the a version. :(

wahn
Posts: 15
Joined: Fri Nov 15, 2002 10:27 pm
Location: London
Contact:

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

Post by wahn » Thu Aug 21, 2003 5:39 pm

Hi Michael,

First of all: Thanks that someone took care about the Python API !!! :wink:

As one of the old NaN I (the I stands for "Not a Number" before the first bancruptcy - a few people worked for NaN II as well) guys ( :twisted: ) I got the source code and debugged a bit. So one thing I came across is a problem with getting the parameters into Blender. Try the following Python script (inspired by the new Python docs):

import Blender
scene = Blender.Scene.getCurrent () # get the current scene
object = Blender.Object.New ('Camera') # make camera object
camera = Blender.Camera.New ('ortho') # make ortho camera data object
object.link (camera) # link camera data with the object
scene.link (object) # link the object into the scene
object.setLocation(0.0, -5.0, 1.0) # position the object in the scene
Blender.Redraw() # redraw the scene to show the updates.


You will run into a problem with the line:

object.setLocation(0.0, -5.0, 1.0)

This is caused by the following line (line 1047 in source/blender/python/api2_2x/Object.c [function Object_setLocation]):

if (!PyArg_Parse (args, "fff", &loc1, &loc2, &loc3))

It should read:

if (!PyArg_Parse (args, "(fff)", &loc1, &loc2, &loc3))

This is true for a lot of other lines ...

Cheers,

Jan

breakin
Posts: 0
Joined: Fri Aug 22, 2003 3:33 am

Post by breakin » Fri Aug 22, 2003 4:30 am

myObject=Blender.Object.Get('myObjectName')
myObject.setName('myNewObjectName') # line 4

fails (blender 2.28a, rh9) with the following error:

Traceback (most recent call last):
File "Text.001", line 4, in ?
AttributeError: expected a String as argument

---

I'm completely new to the world of Blender and that of Python so I might be way off, but no matter how I tried I didn't get the scene hiarchies to work properly.

If I created two objects (a,b) and made a the parent of b (a.makeParent(list including b) object b still reported 'none' as its parent. IMHO getChildren should only return root-objects and then the children-Obects can be polled for their children. How have you solved this?

There seems to be no getChildren-method for the class Object so I really don't see how you can store a hiarchy (there is getParent, makeParent though so it's possible, but you have to go from the bottom and up which is annoying)... Did I miss anything in the API (or is there something wrong with the API-ref?)

Locked