Forum: Poser Python Scripting


Subject: Need help with this script: have I nested loops?

Tguyus opened this issue on May 06, 2008 · 8 posts


Tguyus posted Sun, 11 May 2008 at 4:13 PM

Quote - Markschum has caught the problem.

If you're only going to set the value at keyframes, you don't need the
outer loop on range(scene.NumFrames()).  The while loop based
on NextKeyFrame will do the whole job.

This would do well enough in each case:

for parmName in copyParms2:
..... parmTo4 = leftthighTo.Parameter(parmName)
..... parmTo5 = leftbuttockTo.Parameter(parmName)
..... parmTo6 = lefthipTo.Parameter(parmName)
......scene.SetFrame(0)
......while 1:
....... parmTo4.SetValue(leftthighFrom.Parameter("Bend").Value() * -0.01)
....... parmTo5.SetValue(leftthighFrom.Parameter("Bend").Value() * -0.01)
....... parmTo6.SetValue(leftthighFrom.Parameter("Bend").Value() * -0.01)
....... nextKey = parmFrom.NextKeyFrame()
....... if (nextKey == None):
............ break
....... scene.SetFrame(nextKey)

hmmm... doesn't work, alas.

First fix attempt = deleted the "for frame in range(scene.NumFrames()):" line only.  This made it match the code pasted above in the quote, with periods = spaces.  Led to syntax error on "scene.SetFrame(0)" line.  

Second fix attempt = various experiments revising indentations.  Led to errors of either syntax for lines in the looping routine (e.g., the "while 1:" line) or undefined parameter error for "parmFrom".

So... not sure what to try next.  If anyone has suggestions, I'd really appreciate it!  And thanks again for your help so far.

cheers...