Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   Paste Relative (https://simplymaya.com/forum/showthread.php?t=42994)

gsur 10-02-2017 06:56 AM

Paste Relative
 
I want to write a command that will paste animation relative to an existing key value.
This works, but if you’re pasting in the middle of a bunch of animation, it will shift the stuff on the right over… it should paste without shifting. Any ideas?

Code:

float $currentFrame = `currentTime -query`;
pasteKey -time $currentFrame -option insert -connect 1 -timeOffset 0 -floatOffset 0 -valueOffset 0;

Thank you in advance.

NextDesign 11-02-2017 03:14 PM

Try -option replace. Insert will shift the keys, just like you're experiencing.

gsur 12-02-2017 05:17 AM

The "replace" flag requires a time RANGE, so I can't use "-time $currentFrame".
How can I find out the time range of the data on the clipboard?

For example: I copied 3 keyframes, between frames 1 and 10.
My paste command would then be -time "1:10".... but how do I query those values?

NextDesign 13-02-2017 10:37 PM

You will need to jump into the Maya API for this information.

Look at: http://download.autodesk.com/us/maya...clipboard.html

Another way is to write out a file which contains the length when you copy the keys. Use "getenv TMPDIR" to get the temp directory, and store it in there. When you paste, read the data in the file, and there you go.

gsur 27-02-2017 04:02 AM

Not sure if there's a simple solution for this.

Just to be clear, here's what I'm trying to achieve:
- Copy the red curve into green curve.
- The animation should paste-connect to key A's value (it should paste as -10, not +10).
- It should leave key B intact (don't shift it over).

I mocked up my desired outcome in Photoshop:
http://i.imgur.com/vwu6EvY.png
http://i.imgur.com/Ab4581J.png

I appreciate the help.

NextDesign 27-02-2017 11:35 PM

Hmm, I see. That's a bit trickier. My first thought would be to store the time/value pairs of each key into an array, move the target curve over by the length of the array (time delta of the selected keys), then loop through each element of the array and set a key where the time is plus the offset (difference between first selected key and the target curve), and the value is plus or minus the value of the first target key.


All times are GMT. The time now is 07:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018