Need help with exporter script

I desparately need some help, please.

I need an exporter for a free racing sim that will export animation info from Blender in a specific format.

Any help by one of the Python gurus will be forever appreciated, thank you.

I couldn’t attach a .txt file so here is the format needed.

*SKELETONINFO {
*VERTCOUNT 135
*INDEXCOUNT 798
*FRAMERATE 30
}
*BONE {
*BONENAME Bip01 Pelvis
*VERTEXWEIGHTS {
*MESHNAME Box02
*WEIGHT 0 0.565037
*WEIGHT 1 0.340933
*WEIGHT 2 0.281709
*WEIGHT 3 0.450166
*WEIGHT 4 0.381702
*WEIGHT 67 0.552552
*WEIGHT 68 0.332404
*WEIGHT 69 0.441996
*WEIGHT 70 0.279129
*WEIGHT 76 0.982807
*WEIGHT 84 1.0
*WEIGHT 88 0.283147
*WEIGHT 132 1.0
}
*PARENTNAME Bip01
*POSXYZ 0.405173 0.529669 -0.00982666
*ROXYZW -0.298676 -0.260401 0.705785 0.58724
*SCAXYZ 1.0 1.0 1.0
*LENGTH 0.00216875
*ANIMATION {
*ANITIME 0f
*ANIPOSXYZ 0.0 0.0 0.0
*ANIROXYZW 0.0 0.0 0.0 1.0
*ANISCAXYZ 1.0 1.0 1.0
*ANITIME 1f
*ANIPOSXYZ -0.00152341 0.0 -0.000235794
*ANIROXYZW 0.0 -0.000156247 0.0 1.0
*ANISCAXYZ 1.0 1.0 1.0
*ANITIME 2f
*ANIPOSXYZ -0.00303847 0.0 -0.00044855
*ANIROXYZW 0.0 -0.000499983 0.0 1.0
*ANISCAXYZ 1.0 1.0 1.0
*ANITIME 3f
*ANIPOSXYZ -0.0045588 0.0 -0.000663602
*ANIROXYZW 0.0 -0.000843736 0.0 1.0
*ANISCAXYZ 1.0 1.0 1.0
*ANITIME 4f
*ANIPOSXYZ -0.0060986 0.0 -0.000905535
*ANIROXYZW 0.0 -0.000999983 0.0 1.0
*ANISCAXYZ 1.0 1.0 1.0
}
}

Give me a (short) .blend with such an animation (truncated to a minimum needed).
And a lot of questions remain:
A skeleton are the bones of … and what do you mean with, a bone has a head and a tail = your VERTCOUNT ???
*VERTCOUNT 135
*INDEXCOUNT 798

Meaning (at least for me) your description is not sufficient

Thanks for the reply, PKHG.

I’m not sure exactly what the vertcount and indexcount are but will go back and review the info that I have and try to give a coherant explaination tomorrow night.

I’m having trouble posting info as the forum won’t let me post what I desire to say, bummer.

I’m a nu-be to this forum.

After some time (and posts) you may upload images and use [ code ] and its counterpart …

I’ll try an image that might help.


hey it worked. you can see that I’m using Blender 2.45. I think I got the vertcount right but not sure.

PKHG,
Have I been fogotten. This thread is getting buried.

somewhere between betacam and dinosaurs.

Thanks for a reply batFINGER,
I’m trying to learn Python and having fits. Currently I have figured out how to get the first four items I need but can’t figure out how to get info about the armature’s. Stuff like bone name, etc.

Any help will be appreciated, thank you!

you can use print(dir(armatureobject)) it will display the functions.

Thank you Darknet. I’ll give it a try and probably be back whit more questions.

Here is the code I’m using:

def write_obj(filepath):
out = file(filepath, ‘w’)
sce = bpy.data.scenes.active
ob = sce.objects.active
me = ob.getData(mesh=1)
mesh=ob.getData(mesh=1)
vlen1=len(me.verts)
print ‘verts’, vlen1
out.write(ob.type + ": " + ob.name + "
“)
out.write(”* SKELETONINFO {
")
out.write(tab + "* VERTCOUNT " + len(me.verts) + "
")

It gives a “Can’t concatanate ‘str’ and ‘int’ objects” error.

How do I get the vlen1 or len(me.verts) to write to the file. It writes to the Blender console with no problem.

Any info or help will be appreciated, thank you.

Hello boomer541,
If you write in a text file, you need to convert all types to the string type.
Check this page :
http://docs.python.org/py3k/library/string.html#string-formatting

example:
out.write("An integer: {0}
A float: {1} ".format(12,0.2659)

Thanks Stun,
None of the tutorials on i/o s c r i p t s told me that ALL objects have to be strings to write to a file. After I posted the problem I found a tutorial that had the Think Python Book and in the Files section that info was there. That was my problem and now is solved and I can go on.

I still need to figure out how to get the framerate and bone info from Blender for the animation exporter that I’m trying to make.

I got the info to get the framerate value by using google!

Now perhaps I will have to use google to find out how to get the bone info or perhaps one of the Python experts on Blenderartists can help me with that problem.

Are there any Python experts that can help me get the info I need to complete the exporter I’m trying to make?

Sorry, it looks like you are using an OLD Blender …
Check if your ‘animation’ will run in Blender 2.57, if so, I know something about finding info about bones …

Thanks for the reply PKHG!
Yes I still use ver. 2.45 as I don’t like the 2.5x GUI. The basics of extracting bone info from v.2.57 should be adaptable to 2.45 with a little tinkering with Python.

I got the bone name. Now I need to get the rest of the Bone info.
There is also a Bip01 that I need to get but don’t know what that is in the animated object.

Any, ANY help will be appreciated, thank you.

Buried again.
Anyone willing to help make an exporter for 2.4x versions for those Blender users that don’t like the 2.5x version?

Nobody don’t like Blender2.5x, but what are you found in the Blender/Python doc about Bones info?

I finally found some code to get the Bip01 out of Blender and found code to get the vertices influenced by a bone weight info.
Then I’ll need code to get the parentname, scale and length info as I can get the frames and quaternions info.

Signed nobody, LOL