Is it Python/Blender version or the plugin itslef?

Hello, Blender community!

— this part is a quick presentation that you can skip —
I’m a 3DS Max user since v5. A few years ago, I discovered an online game and thought that it would be cool if I could create some fan-arts with originals models and textures. After a long search, I managed to find some tools to do this and found some that would be usefull. I decided then to create my own script for importing those models, up to bones hierarchy and vertices weights. The only thing is that I have to convert original game files into Metasequoia files and then fiddle with them.
I then realized I was losing some important informations by doing this because I discovered a Blender plugin that could perfectly import those files, up to animation keyframes, by working on the original game files.
This plugin is a very good reason to give blender another try but I’m stuck!
– end of the annoying part –

This plugin starts with:

Name: 'PangYa Object (.pet .mpet .apet .bpet)...'
Blender:<b> 241</b>
Group: 'Import'
Tooltip: 'Import a PangYa Object File.'

I tried to use it in Blender 2.5a and Python 3.1, Blender 2.49 and Python 2.6, and finally Blender 2.41 and Python 2.4. Nothing is working. At best I get a message:

Using Python version 2.4
Traceback (most recent last call):
     File "&lt;string&gt;", line 713, in ?
AttributeError: copy

Is it an error related to Blender/Python version or is it the plugin itself that has a problem?

If anyone can help me to fix this problem I swear I switch definitively to blender :spin:

The Blender: 241 line refers to Blender 2.41 NOT Python 2.41…

Blender 2.5 uses Python 3.1 and a totally different API to previous versions, so its extremely doubtful that the script would run anyway…

Blender 2.49 uses Python 2.5.4 (at least mine does…:yes:), so that might be your problem.

You might try changing the line Blender: 241 to Blender 249, that usually works for me…:yes::yes::yes:

Hope this was helpful…

@edit DON’T FORGET to keep backups of the script in case this doesn’t work…

Well, now I can launch the script, many thanks! The problem now is that when trying to import an object, I have the following error:

TypeError: unhashable type: 'EditBone'

Here is the chunk of code producing the error (bolded):


def create_armature(name, boneChunk):
    print "creating armature and bones..."
    armObj = Blender.Object.New('Armature', name)
    Blender.Scene.GetCurrent().link(armObj)
    arm = Armature.Armature(name)
    armObj.link(arm)
    arm.drawType = Armature.OCTAHEDRON
    arm.makeEditable()
    childBones = {}
    for bone in boneChunk.boneList:
        eb = Armature.Editbone()<b>
        if not childBones.has_key(eb):</b>
            childBones[bone] = []
        if bone.hasParent():
            parent = arm.bones[bone.parent().name]
            eb.parent = parent
            childBones[bone.parent()].append(eb)
#            eb.options = [Armature.CONNECTED]
        eb.head = coordConv * bone.absoluteMatrix().translationPart()
        arm.bones[bone.name] = eb
    for bone, children in childBones.iteritems():
        eb = arm.bones[bone.name]
        # set length
        if len(children) &gt; 0:           # average of children
            av = reduce(lambda a, b: a + b, map(lambda b: b.head, children), Mathutils.Vector(0, 0, 0)) * (1.0 / len(children))
            eb.tail = av
        elif eb.hasParent():            # same as parent
            eb.tail = eb.parent.head
        else:                           # unit
            eb.tail = eb.head + Mathutils.Vector(1, 0, 0)
        if eb.length == 0:
            eb.tail = eb.head + Mathutils.Vector(1, 0, 0)
        # editbone.matrix indicates
        # when 3x3 matrix, direction and roll
        # when 4x4 matrix, direction, roll and head position
        # set rotation
        eb.matrix = boneConv * coordConv * bone.absoluteMatrix().rotationPart() * coordConv_invert
    arm.update()
    return armObj

Is the code deprecated? (this script has been written in 2007/04)

Your welcome… It looks like the script is relying on the way dictionaries where handled in the python used by Blender 2.41, but which has since been changed in Python 2.5.? and later, I’m not up to-date with python programming :(… I’m certain that one of the others may well be able to help you more…:yes:

I already tried the Blender & Python apparently used for this script (2.41)

I also tried to use the actual syntax wich is

if not eb in childBones:

but I have the same error. :frowning:
The file format could have been slightly changed but I highly doubt it as there would have been a tedious amount of work to process something like 2k models.

Any clues on how to make this script working flawlessly with the actual (and I hope future) stable version(s) of blender? :confused:

Sorry, haven’t a clue :o… But i do know that it would need an almost complete rewrite for Blender 2.5 and beyond, as the API’s are, I believe, being radically changed…:yes:

…I hope this isn’t putting you off using Blender

Well, I have managed to debug the script, knowing nothing to Python!:cool:
Now, I’ll have to deal with Blender’s UI and logic :o

Thanks for your help! :slight_smile:

try using blender 2.41, then save and open in 2.49 .
I really dunno what I am talking about.

It’s me, again :o
I’m converting this script to Blender 2.5/Python3.1
I converted the print to print() and other things like that but I’m stuck with


import Blender
from Blender import NMesh, Armature, Material, Texture, Image, Mathutils, Registry, Text, Ipo, IpoCurve
from Blender import sys
from Blender.Object import Pose

And I have the error message:


ImportError: No module named Blender

I haven’t found a document describing python changes coming along with Blender 2.5.
Any idea?

up!
This seems the last thing I need to get this plugin working :frowning:
Any idea on how to correctly import those modules in the new Blender/Python combo?

import Blender
from Blender import NMesh, Armature, Material, Texture, Image, Mathutils, Registry, Text, Ipo, IpoCurve
from Blender import sys
from Blender.Object import Pose

you can’t… because the new blender api is completely different :confused: in 2.5… :confused: but will be really more powerful, well structured and pythonic :slight_smile:
but what you’ve done should be almost ok for blender2.49/python 2.4, which will be used at least the whole next year I suppose, for the script side.