Working with pathAnimation - PyMel

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Search this Thread Display Modes
  3 Weeks Ago
Working with pathAnimation - PyMel

Is there a more elegant way to assign a pathAnimation and set the uValuewith PyMel? I've headed down the PyMel route to avoid the string references, hoping that when I create things it will return nodes. But it seems that creating a pathAnimation returns a string which I'm getting as a PyNode in an what feels like an awkward way.


import pymel.core as pm
thePath = pm.PyNode('bezier1')
theLoc = pm.PyNode('locator1')
pa = pm.pathAnimation( theLoc, c=thePath, follow=False, fractionMode=True)
pathAnim = pm.PyNode(pa)
pathAnim.uValue.set(.3)
__________________
Not bad. For a hughman.
 
  3 Weeks Ago
You are right, returning a string instead an object is a non-pymel like behaviour, so I fear there is no other way to use it as a pymel object. btw.: you do not need to create pymel objects from the curve and the locator in this case.
__________________
www.renderwiki.com - www.openmaya.net
 
  3 Weeks Ago
Hey Haggi, thanks for your reply. I did find it weird that pathAnimation returns a string, whereas pointConstraint and aimConstraint both return nodes.
Thanks also for the feedback on not needing pyMel objects. I often build my tools in little chunks to test things in a way that is simple to understand and get working before incorporating them with the rest. So this is just the way that I'm grabbing things that are already in the scene which would be fed to the function as pyMel nodes in the bigger tool.

Thanks.
__________________
Not bad. For a hughman.
 
  3 Weeks Ago
I'm having another issue with pathAnimation. I'm using it to spread locators along a spline.

pa = pm.pathAnimation( newLoc, c=linkedCurve, follow=False, fractionMode=True)
pathAnim = pm.PyNode(pa)
pathAnim.uValue.set(uVal)


Which seems to work fine until I move the time slider and all the points move back to a uValue of 0.
Obviously there's variables in my code that aren't defined here, so this snippet of code won't work on it's own.
How do I get this uValue to stick?

Cg.
__________________
Not bad. For a hughman.
 
  3 Weeks Ago
When you create a motion path it comes already hooked up to the timeline by a node of type animCurveTL. You must break the connection if you don't want scrubbing the timeline to affect your uValue.

pathAnim = pm.PyNode("motionPath1")
animTL = pm.PyNode("motionPath1_uValue")

animTL.output.disconnect(pathAnim.uValue)
 
  1 Week Ago
Thanks for that spire2, Is there a way to get the animTL as a PyNode by just using the pathAnim? Rather than having to resort to getting the PyMel node using the "motionPath1_uValue" string? Or should I just make the string by using the string that's returned in my original pa variable and just add "_uValue" to it? All this string reference just seems janky. But if it's the right (or at least acceptable) way to do this, then I'll run with it.

Cheers,
Cg.
__________________
Not bad. For a hughman.
 
  1 Week Ago
spire2, I assume that once I have disconnected the output from the uValue from the input of the motionPath, I should delete the unused node?Likely with pm.general.delete() ?

Sorry I'm relatively inexperienced with Maya and PyMel compared to 3dsmax/Maxscript.

Cg.
__________________
Not bad. For a hughman.
 
  1 Week Ago
Yes you can easily derive the animTL node, using inputs() or listConnections() for example. Something like:

import pymel.core as pm

moPath = pm.PyNode(pm.pathAnimation('pSphere1', c='curve1'))

animTL = moPath.uValue.inputs()[0]
animTL.output.disconnect(moPath.uValue)
pm.delete(animTL)


It all depends how robust you want to be, I mean if you don't care about a handful of stray animCurveTL nodes floating around you could just do:

moPath = pm.PyNode(pm.pathAnimation('pSphere1', c='curve1'))
moPath.uValue.disconnect(inputs=True)


Or if you wanted to go the other direction and be especially fastidious, in the first version you could check to be sure inputs() returns something before dereferencing it. I'm confident enough there will be something there right after the mopath is created, but if this script was determining whether or not nukes get launched I'd probably test it anyway
 
  1 Week Ago
Thanks for your time and wisdom.

Cg.
__________________
Not bad. For a hughman.
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:02 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.