— 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 –
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 "<string>", 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:
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) > 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.
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?
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:
you can’t… because the new blender api is completely different in 2.5… but will be really more powerful, well structured and pythonic
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.