Introduction to Maya - Modeling Fundamentals Vol 2
This course will look in the fundamentals of modeling in Maya with an emphasis on creating good topology. It's aimed at people that have some modeling experience in Maya but are having trouble with complex objects.
# 1 10-02-2017 , 06:56 AM
Registered User
Join Date: Feb 2016
Posts: 6

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.

# 2 11-02-2017 , 03:14 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Try -option replace. Insert will shift the keys, just like you're experiencing.


Imagination is more important than knowledge.
# 3 12-02-2017 , 05:17 AM
Registered User
Join Date: Feb 2016
Posts: 6
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?

# 4 13-02-2017 , 10:37 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
You will need to jump into the Maya API for this information.

Look at: https://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.


Imagination is more important than knowledge.

Last edited by NextDesign; 13-02-2017 at 10:45 PM.
# 5 27-02-2017 , 04:02 AM
Registered User
Join Date: Feb 2016
Posts: 6
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:
user added image
user added image

I appreciate the help.

# 6 27-02-2017 , 11:35 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
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.


Imagination is more important than knowledge.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads