SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.


SM Forums / Maya Questions / Programming / Paste Relative

Programming MEL Scripts, Expressions & Programming Related Topics

Join the conversation. Reply to post
 
Thread Tools
10-02-2017, 06:56 AM   #1
gsur
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.
  Reply with quote
11-02-2017, 03:14 PM   #2
NextDesign
Technical Director
 
NextDesign's Avatar
 
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.
  Reply with quote
12-02-2017, 05:17 AM   #3
gsur
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?
  Reply with quote
13-02-2017, 10:37 PM   #4
NextDesign
Technical Director
 
NextDesign's Avatar
 
Join Date: Feb 2004
Posts: 2,988
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.
__________________
Imagination is more important than knowledge.

Last edited by NextDesign; 13-02-2017 at 10:45 PM.
  Reply with quote
27-02-2017, 04:02 AM   #5
gsur
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:



I appreciate the help.
  Reply with quote
27-02-2017, 11:35 PM   #6
NextDesign
Technical Director
 
NextDesign's Avatar
 
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.
  Reply with quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
very simple Melscript needed...move selected object to origin (0,0,0) juggler7 Maya Basics & Newbie Lounge 35 14-07-2015 02:12 AM
Copy and paste surface settings. djwaterman Maya Modeling 9 01-02-2012 09:11 PM
Copy and paste Phizzon Maya Basics & Newbie Lounge 3 19-06-2008 09:13 PM
paste opposite pose script scoonie_p Programming 0 16-04-2006 04:00 PM
Whats the rule on copy and paste? wgreenlee1 Maya Basics & Newbie Lounge 2 04-05-2003 02:45 PM