Please help me get this python script to work

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Posts: 0
Joined: Tue Jun 17, 2003 2:33 am

Please help me get this python script to work

Post by anotherfantasy » Tue Jun 17, 2003 2:58 am

I want to convert my models with animations to a .X file (the Direct X Format). 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 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.

Posts: 180
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

Post by Michel » Tue Jun 17, 2003 10:58 am

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,

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

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

Post by 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

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 "", line 42, in write Materials
mesh = Blender210.getMesh(
TypeError: argument1: expected string, None found

After looking in (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(
for index in range(len(object.materials)):
namecol = object.materials[index]
mat = Blender210.getMaterial(namecol)

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.

Posts: 0
Joined: Mon May 19, 2003 3:44 am

Post by 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 and look at the python docs 2.25

Post Reply