Record curve position in the loop then build your curve outside of it...

Envoyé de mon iPhone

Le 27 févr. 2011 à 22:06, Martin La Land Romero <martinmrom...@gmail.com> a
écrit :

Hello and thanks  dmon shelton,

I tried this but still nothing :(

frameStart = 1

frameStop = 50

step = 1

myObject = cmds.ls(selection = True)

#This loop queries the position of the animated object and creates a curve
based on its position.

for object in myObject:

i = frameStart

while i <=frameStop:

#yield i

i += step

print('The current frame is', cmds.currentTime( i, edit = True))

animationCurve = cmds.curve( p = [(0,0,0)], name = ('Jack_' + str(object) ))

time = cmds.currentTime(i, edit = True)

#Get the object position on everyFrame.

pos = cmds.xform((object), r=True, query = True, t=True )

cmds.curve(animationCurve, append = True, p = (pos))


martin

On Sat, Feb 26, 2011 at 11:08 PM, damon shelton <damondshel...@gmail.com>wrote:

> in your loop you need to build up all the point positions
>  then after the loop you need to draw your curve, setting all your points
> in order at once
>
>
> On Sat, Feb 26, 2011 at 10:39 PM, martinmrom...@gmail.com <
> martinmrom...@gmail.com> wrote:
>
>> Hello Everyone,
>>
>> I am currently working on a basic tool, it is WIP. The purpose of the
>> tool is to create a curve from an object's translation.  I know that
>> Maya has something like this already however, I wanted to create the
>> actual script myself using Python.
>>
>> I have a problem with the script, it seems to be creating a curve at
>> every frame instead of creating one whole curve drawing the whole
>> path, any hints?
>>
>> Thanks so much!
>>
>> import maya.cmds as cmds
>> """
>>
>> This tool creates a curve or multiple curves from an animated object's
>> translation.
>> Author:
>>    Martin LaLand Romero
>>
>> """
>>
>> def main():
>>    """
>>    This function runs the genCurvefromObj function.
>>    """
>>    for i in genCurvefromObj(1, 95, 1):
>>        print(i)
>>
>>    """
>>    This function generates a curve based on the object's animation
>> path.
>>    """
>> def genCurvefromObj(frameStart, frameStop, step):
>>    myObject = cmds.ls(selection = True)
>>
>>    #This loop queries the position of the animated object and creates
>> a curve based on its position.
>>    for object in myObject:
>>        i = frameStart
>>        while i <=frameStop:
>>            yield i
>>            i += step
>>            print('The current frame is', cmds.currentTime( i, edit =
>> True))
>>            animationCurve = cmds.curve( p = [(0, 0, 0), (0, 0, 0),
>> (0, 0, 0), (0, 0, 0)], name = ('Jack_' + str(object) ))
>>            cmds.currentTime(i, edit = True)
>>
>>            #Get the object position on everyFrame.
>>            pos = cmds.xform((object), r=True, query = True,  t=True )
>>
>>            cmds.curve(animationCurve, append = True, p = pos,)
>>            cmds.delete(animationCurve + ".cv[0]")
>>
>> if __name__ == "__main__": main()
>>
>> Even after revising the loop as shown below, the tool still doesn't
>> work.
>>
>>
>> frameStart = 1
>> frameStop = 100
>> step = 1
>>
>> myObject = cmds.ls(selection = True)
>>
>>    #This loop queries the position of the animated object and creates
>> a curve based on its position.
>> for object in myObject:
>>    i = frameStart
>>    while i <=frameStop:
>>        #yield i
>>        i += step
>>        print('The current frame is', cmds.currentTime( i, edit =
>> True))
>>    animationCurve = cmds.curve( p = [(0, 0, 0), (0, 0, 0), (0, 0,
>> 0)], name = ('Jack_' + str(object) ))
>>    cmds.currentTime(i, edit = True)
>>
>>    #Get the object position on everyFrame.
>>    pos = cmds.xform((object), r=True, query = True,  t=True )
>>
>> cmds.curve(animationCurve, append = True, p = pos,)
>> cmds.delete(animationCurve + ".cv[0]")
>>
>> Thank you guys,
>>
>> Cheers
>> Martin
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>>
>
>  --
> http://groups.google.com/group/python_inside_maya
>



-- 
Martin La Land Romero
www.martinromerovfx.com
http://martinromerovfx.blogspot.com/
martinmrom...@gmail.com
(415)261-2172

-- 
http://groups.google.com/group/python_inside_maya

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to