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 »

agreed, but it sure beats having to rename all the functions in the whole script.

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

reimpell
Posts: 0
Joined: Wed Oct 01, 2003 5:09 pm

FileSelector after DrawProgressBar crashes

Post by reimpell »

Hi!
Blender crashes if FileSelector is used after DrawProgressBar.

Code: Select all

import Blender

def my_callback(filename):
  print "You chose the file:", filename

Blender.Window.DrawProgressBar (0.0, "Importing data ...")
Blender.Window.FileSelector (my_callback, "Choose one!")
Kind regards
Michael

Used versions:
Blender 2.28c (blender-2.28c-linux-glibc2.2.5-i386)
Python 2.2.2

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

applying matrix on a vertex.

Post by assassin »

theeth wrote:apply the deformation matrix to the vertice coordinates.

Martin
Yeah. But can I do that.

Just tell me if this works

if this is the deform matrix
i0 i4 i8 i12
i1 i5 i9 i13
i2 i6 i10 i14
13 i7 i11 i15

so does this work?

newx=(x*i0)+(y*i1)+(z*i2)+i3
newy=(x*i4)+(y*i5)+(z*i6)+i7
newz=(x*i8)+(y*i9)+(z*i10)+i11

Ok . Does this work? And you say that i have to use deform matrix
rather than the getMatrix() function.

If this is not right , please correct me.

der_ton
Posts: 0
Joined: Mon Oct 20, 2003 1:02 am

Post by der_ton »

The getParent() method of a Bone doesn´t return the parent, but returns 0 if the bone has no parent, or 1 if it has, acting like the hasParent() method.
(using 2.28c Win, Python 2.2.3)

I couldn´t find it any of the other posts in this topic, sorry if it´s a repost.

der_ton, desperately waiting for more armature/bone-related API functionality :)

Snafubar
Posts: 0
Joined: Thu Oct 23, 2003 6:20 pm

API Doc is missing ipo.getCurves()

Post by Snafubar »

I suspect the API Document is missing ipo.getCurves().

You can get the ipo of an object, but you can't get the curves of the ipo!
Well, actually, you can... but I had to find it!

strings blender | grep -i curve



Jamie.

gpg
Posts: 2
Joined: Mon Oct 21, 2002 10:24 pm

Post by gpg »

Sorry, I forgot to document this function...

I do it right now.

BTW, I have implemented a probably more handy function : getCurve(string)
to which you pass the name of the requested IpoCurve. It returns an IpoCurve object, not a list.

Tks for your attention!

artificer
Posts: 0
Joined: Fri Sep 12, 2003 2:39 pm
Location: Melbourne, Australia

Facemodes screwed up in Python

Post by artificer »

Hi,
Sorry if this has been mentioned before, I've searched for it, but can't find it anywhere.

Basically, the problem appears to be that the NMFace.mode field is uninitialised when getting the mesh data from a newly created mesh.
It stays this way even through file saves/loads.
This leads to completely random face modes.
The problem goes away if you go into face-select mode and back out once.

The following script demonstrates the problem:

Code: Select all

from Blender import NMesh, Object, Window

selection = Object.GetSelected()

for obj in selection:
  if obj.getType() == "Mesh":
    mesh = NMesh.GetRawFromObject(obj.getName())

    print "facemodes for", obj.getName()

    for face in mesh.faces:
      print face.mode,

    print
Note that the facemodes are different every time the script is run, which suggests to me that the mode field is freshly created with each new NMesh object, rather than copied across from an uninitialised blender field.

Thanks for any help with this (it's kinda screwing up my export script),
artificer

artificer
Posts: 0
Joined: Fri Sep 12, 2003 2:39 pm
Location: Melbourne, Australia

Re: Facemodes screwed up in Python

Post by artificer »

OK, I've just tested it with 2.30, and the problem is still there.
After more experimentation, I've found that the problem only appears
when a mesh has no UV coordinates: Create coordinates -> all facemodes
are 1, delete coordinates -> all facemodes are random.

Just wondering, does this thread still get read?
Seems like this post has been here a while with no response. :-(

Thanks,
artificer

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

Re: Facemodes screwed up in Python

Post by Michel »

artificer wrote:Just wondering, does this thread still get read?
Seems like this post has been here a while with no response. :-(
Hi,

This thread has been started when the pre release of 2.28 has been made. At that moment there was no official release number in the bug tracker.
Now with the 4th official release after that particular pre-release (2.28, 2.28a, 2.28c and 2.30), problems should be reported in the bug tracker.

I'm sorry that I didn't post this comment just after 2.28 had been released; it could've saved some troubles :oops:

You can find the tracker through the projects link at the top of the blender.org page.

With regards,
Michel
You can have one of two things: Progress or Progress Reports.

artificer
Posts: 0
Joined: Fri Sep 12, 2003 2:39 pm
Location: Melbourne, Australia

Post by artificer »

Michel wrote:Now with the 4th official release after that particular pre-release (2.28, 2.28a, 2.28c and 2.30), problems should be reported in the bug tracker.

Ah, OK, I'll do that then. :)

Thanks,

artificer

Snafubar
Posts: 0
Joined: Thu Oct 23, 2003 6:20 pm

update(1) does not do a full update...

Post by Snafubar »

Although the docs do not explicitly state that 'update(1)' will update the scene's matrices and mesh deformations, I believe it should.

I posted a workaround to the getMatrix() thread, about using RedrawAll() after a setCurrent(frame) to make blender do a real full update, updating the scene's transforms, according to IPO curves, etc...
As well, that workaround works for the scene's mesh deformations: calling RedrawAll() makes sure the getRawObject() call produces the properly deformed mesh.

HOWEVER :!: If the 3D view is not visible, then RedrawAll( ) will NOT update the transforms and meshes! So, this workaround only works if the 3D view is visible.

That is why I think update(1) should do this: RedrawAll is not guaranteed.
Of course, you are free to think I'm on crack...

Thanks,
Jamie.[/i]

philetus
Posts: 0
Joined: Wed Nov 12, 2003 2:37 am

unable to import library modules

Post by philetus »

hi,

on windows xp the following code:

Code: Select all

import Blender
import math
import random
results in the error:

Code: Select all

ImportError: No module named random
'import site' failed; use -v for traceback
sys_init:warning - no sitedirs added from site module
it seems like the python 'Lib' directory is not on the path, but sys.path.[0] is 'C:\Python23\Lib', which I think is right.

any suggestions how to load library modules?

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

Re: unable to import library modules

Post by Michel »

philetus wrote:hi,

on windows xp the following code:

Code: Select all

import Blender
import math
import random
results in the error:

Code: Select all

ImportError: No module named random
'import site' failed; use -v for traceback
sys_init:warning - no sitedirs added from site module
it seems like the python 'Lib' directory is not on the path, but sys.path.[0] is 'C:\Python23\Lib', which I think is right.

any suggestions how to load library modules?
Hi,

You appear to have installed Python 2.3. Blender currently only supports Python 2.2.x. At Elysiun you can find a lot more information on how to get Python to work in Blender. Click here.

I'm locking this topic now because the intend of the topic was to have problems in the new API reported before an official blender release was made (before 2.28 ). No offense meant to any of you who have been posting new messages after 2.28 of course; just post new messages or report bugs in the bug tracker :)

With regards,
Michel
You can have one of two things: Progress or Progress Reports.

Locked