Please help me get this python script to work

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

anotherfantasy
Posts: 2
Joined: Tue Jun 17, 2003 2:33 am

Please help me get this python script to work

Postby anotherfantasy » Tue Jun 17, 2003 2:58 am

I want to convert my models with animations to a .X file (the Direct X Format). http://space.tin.it/clubnet/arbenom/Export.htm has a python script that was supposed to do the job but I can't get it to work.

I'm using Blender 2.27. The webpage says that 2.2 and higher is supported. I downloaded Python 2.3 into C:\Python23.

After I open up the .blend file that is included in the exporter download, I tried to run it with Alt+P. The Blender console says that line

import Blender210

is no good. I comment it out with a # and attempted to run it again. The console now says that line

import string

is no good. I then put all the python scripts and the .blend file into C:\python23\lib, which is where string.py is.

It still doesn't work. If I comment out more stuff, It still complains about not being able to import the DirectXExport modules. Please help me.

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

Re: Please help me get this python script to work

Postby Michel » Tue Jun 17, 2003 10:58 am

Hi,
anotherfantasy wrote:import Blender210

The above line in the script means that it's a script written for the Blender 2.10 Python API. This API is still available in Blender 2.23, but not in 2.26 and later.
So you'll have to use Blender 2.23 or convert the script to use the newer API.
Furthermore, it looks as if your PYTHONPATH is not correct. Look in the Python forum at Elysiun for tips on how to set the PYTHONPATH.

With regards,
Michel

anotherfantasy
Posts: 2
Joined: Tue Jun 17, 2003 2:33 am

I got it to work... except this one last part.

Postby anotherfantasy » Wed Jun 18, 2003 8:56 pm

Thanks for your help. I'm able to get it to work almost completely. Now I have a new problem.

I'm using Blender version 2.23 with Python 2.3

I'm trying to export animations to .X files using the Direct X export suite at http://space.tin.it/clubnet/arbenom/Export.htm

Seems as if only version 2.23 works. I am able to export meshes and simple animations with it. It is working properly. However, when I attempt to export animations using armatures, I get this error in the console.

File "AnimX.py", line 42, in write Materials
mesh = Blender210.getMesh(object.data)
TypeError: argument1: expected string, None found

After looking in AnimX.py (it's a file included with the Direct X export suite) the function of interest is

def writeMaterials(self,name,object):
object = Blender210.getObject(name)
mesh = Blender210.getMesh(object.data)
for index in range(len(object.materials)):
namecol = object.materials[index]
mat = Blender210.getMaterial(namecol)
self.file.write("Material")

Apparently Blender210.getObject() takes a string for a parameter but Blender210.getObject(name).data is not a string. Could someone please help me debug this? I really need this animation exporter. I don't know the data types of the objects and stuff so I'm unable to attempt to fix this on my own. If anyone can point me to documation that descripes the blender objects, that would help too.

Again, higher versions of Blender will not work with this script because of the Blender210 module usage.

paposo
Posts: 2
Joined: Mon May 19, 2003 3:44 am

Postby paposo » Thu Jun 19, 2003 5:15 am

I don't think any of the documentation includes what the blender210 module does. I guess you could open the module's .py file if you had the old versions' source code to see. I was trying to update the quake model importer for blender that used the blender210 module as was able to do the same things by using the blender and nmesh modules instead of mesh and blender210. If your up for a weekend of python training and looking through the blender documentation you could probably rewrite the offensive function. Go to the documentation section in blender.org and look at the python docs 2.25


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests