phlsphr opened this issue on Feb 23, 2001 ยท 7 posts
phlsphr posted Mon, 26 February 2001 at 9:54 AM
Here's the best I can do with the problem of loading in multiple MTs from one file. This script looks at each body part of your figure and loads in MT's for it from preset directories. The morph target target files still have to be individual files with appropriate names (e.g. lShldr1.obj), but I wrote a Maxscript so that my modeling program, 3DMax, takes one big file (the one I was working on) and splits it into files, one for each body part. Still tedious, but it does save time. Hope this isn't too confusing....feel free to suggest improvements. ***************** import poser mtname = "newpython" mtval = 1 mtnamepos = string.join([mtname,"1"],"") mtnameneg = string.join([mtname,"0"],"") print mtnamepos print mtnameneg donegmorph = 1 #--------------------------------- # Get the scene and the importExport object #--------------------------------- currentScene = poser.Scene() imExObject = currentScene.ImExporter() #be sure to manually import something in to set the options options = imExObject.ImportOptions("obj", None) options['Make polygon normals consistent'] = 1 print options fig1 = currentScene.CurrentFigure() #act = currentScene.CurrentActor() #if act == act: for act in fig1.Actors(): name1 = act.InternalName() name2 = name1[0:(len(name1) - 2)] print name2 pathpos = string.join(["temppythontemppos",name2,"1.obj"], "") pathneg = string.join(["temppythontempneg",name2,"0.obj"], "") # print "Importing in Wavefront .obj format..." try: act.SetParameter(mtnamepos,0) if donegmorph: act.SetParameter(mtnameneg,0) except: print "no earlier morph targets found" try: print "here" f = open(pathpos,'r') print f f.close() imExObject.Import('obj', 'File Format Wavefront', pathpos, options) act2 = currentScene.CurrentActor() geom2 = act2.Geometry() act.SpawnTargetFromGeometry(geom2,mtnamepos) act.SetParameter(mtnamepos,1) currentScene.DeleteCurrentProp() if donegmorph: #act.SpawnTarget(mtnameneg) #act.SetParameter(mtnameneg,-1) imExObject.Import('obj', 'File Format Wavefront', pathneg, options) act2 = currentScene.CurrentActor() geom2 = act2.Geometry() act.SpawnTargetFromGeometry(geom2,mtnameneg) act.SetParameter(mtnameneg,-1) currentScene.DeleteCurrentProp() print "Import succeeded" except: print "Import failed -- please check the file name"