EDIT1: I need to take a new approach. It seems that getdata() just returns vectors.
How would I set the active shape key in blender through python? I’ve noticed that the active shape key can be accessed like a mesh.
EDIT2: Ok, I see how to set the active shape key, with object.activeshape=number. But the screen doesn’t update to reflect the newly selected key until I go into and out of edit mode. How would I tell blender to update the screen?
Hmmm, I can do it as:
But there has to be a better way.
Also, Is it just me, or is the blender python api impossible to go through for a newbie? I’m having so much trouble finding what I need.
EDIT3: Wow, why has noone told me about the interactive python scripter built in to Blender. That thing is awesome and will help me A LOT.
Ignore the text and code below. I’m reworking my approach. I’m just gonna leave it here though.
Ok, how would I go about getting the normal of the vertex? If I can get that, I can probably finish this up.
Here’s my code so far. It won’t work for you, as it is a part of another exporter. I’m adding vta functionality to it. I know the coding that I did in it sucks, but I just started learning python the other day.
I use bits of code out of http://blenderartists.org/forum/showthread.php?t=162747 , I hope lonewolfarcher doesn’t mind.
Right now I have it so when you select the VTA option in the exporter, it asks for a filename. Then it gives a pop-up menu with a list of all the shape keys and an option for all of them. When you select something, it prints out the verts of the shape key you selected to the command line.
class VtaExport ( BaseExport ):
def __init__( self ):
BaseExport.__init__( self )
def getExportFilename( self, filename ):
return filename[: -( len( filename.split( '.', -1 )[ -1 ] ) + 1 ) ] + '.vta'
def main( self ):
Blender.Draw.PupMenu("Error: Select a single object.")
if not me.key:
Blender.Draw.PupMenu("Mesh doesn't have any Shape Keys")
blocknames = ""
for block in me.key.blocks[0:km]:
choice = Blender.Draw.PupMenu("Select Shape Key%t"+blocknames)
all_sel = 0
if nameList[choice-1] == "All":
all_sel = 1
all_list = [b.name for b in me.key.blocks]
print "Writing %s:" % all_list
print "Writing %s:" % nameList[choice-1]
numtouse = 1
numtouse = len(nameList)-1
choice = 1
blockverts = me.key.blocks[choice-1]
Writing %s:" % nameList[choice-1]
for j in range(n):
print "%f , %f , %f" % (keyverts[j].x, keyverts[j].y, keyverts[j].z)
choice += 1
def Export( self, filename):
error = self.main()
print "Nothing yet. :'("
I really have no idea what I’m doing here…