Dimension3D opened this issue on Feb 11, 2008 · 19 posts
Tguyus posted Thu, 24 April 2008 at 11:02 AM
Quote - > Quote - ... how difficult would it be to add a looping subroutine so the morphs are copied to all frames of an animation?
Should be easy. Add the following code at the beginning of the method copyMorph, and put the current code of this method into the loop:
for f in range(scene.NumFrames()):
scene.SetFrame(f)I haven't tested it, but this should copy the morph setting for each frame in the scene.
Ulp. I'm afraid I'm not much of a pythoner yet, though I'm trying to learn. Seems like I should've been able to get this to work but just couldn't find the right spot to insert the looping code lines.
Here's the code in case D3D or any other python experts are willing to point to the corect insertion point... and thanks! (D3D-- I hope you don't mind my pasting the code in the message. Please let me know if I've done bad.... and thanks again for the great script!)
partialMatch = 1
noJCM = 0
import poser
import string
def copyMorph(figure, conform):
number = conform.Actors()[0].InternalName()
number = number[number.index(':'):]
for figActor in figure.Actors():
try:
conActor = figActor.InternalName()
conActor = conActor[:conActor.index(':')] + number
conActor = conform.ActorByInternalName(conActor)
except:
continue
for figParam in figActor.Parameters():
name = figParam.Name()
if noJCM and (string.find(name, "JCM") == 0):
continue
conParam = conActor.Parameter(name)
if (conParam == None) and partialMatch:
m = 1000
params = conActor.Parameters()
for p in params:
i = string.find(p.Name(), name)
l = len(p.Name()) - len(name)
if i >= 0 and l < m:
conParam = p
m = l
if (conParam != None and ((figParam.IsMorphTarget() and conParam.IsMorphTarget())
or (figParam.IsValueParameter() and conParam.IsValueParameter()))
and conParam.Value() != figParam.Value()):
conParam.SetValue(0)
conParam.SetValue(figParam.Value() - conParam.Value())
scene = poser.Scene()
conform = scene.CurrentFigure()
if conform:
figure = conform.ConformTarget()
if figure == None:
figure = scene.Figures()
for fig in figure:
c = fig.ConformTarget()
if (c != None) and (c.InternalName() == conform.InternalName()):
copyMorph(conform, fig)
else:
copyMorph(figure, conform)
scene.Draw()