PDA

View Full Version : Mel script for selecting animated objects


thebrianproject
10-13-2010, 09:11 PM
Hey everyone! I remember someone once using a mel script that selected everything with animation in a scene. It made it really easy to do things like move everything with keys on it to start after frame 1. This is what I need to do, but I didn't get the name of the script from the person at the time, and that was a while ago.

Does anyone know what script that I may be talking about?

Morganism
10-13-2010, 11:01 PM
You could try my one:
http://morganloomis.com/download/ml_selectKeyed.py

It selects everything keyed within a hierarchy, though, not the whole scene.

shcmack
10-17-2010, 06:07 PM
I've also made myself something like that. You can choose between selecting all keyed objects at the current frame, or all keyed objects in the entire scene.

//*************************************************************************************************************
// Title: jh_getKeyObjs.mel
// Author: Jørn-Harald Paulsen
// Created: May 17, 2010
// Last Update: June 21, 2010
// Description: Select all keyed objects at the current time (timeslider value)
// Or select all keyed objects in the scene.
//*************************************************************************************************************
// MAIN WINDOW
//*************************************************************************************************************
global proc jh_getKeyObjs() {

//Delete window if it already exists
if (`window -q -ex jh_getKeyObjs`) deleteUI jh_getKeyObjs;

//Create window
window
-topEdge 30 -title "Get keyed objects" -maximizeButton false
-sizeable true -resizeToFitChildren false -menuBar false
-menuBarVisible false -w 300 -h 240
jh_getKeyObjs;

columnLayout -adjustableColumn true;
text -label "\nSelects all objects that has a keyframe at the current time\n" ;
button -label "Select keyed objects at current time" -c jh_getCKeyObjs -bgc 0.15 0.75 0.09;
text -label "\nSelects all objects that has keyframes in the entire scene\n" ;
button -label "Select all keyed objects" -c jh_getKeyObjs -bgc 0.87 0.51 0.42;

window -e -w 300 -h 240 jh_getKeyObjs;
showWindow jh_getKeyObjs;
}

//*************************************************************************************************************
// GET KEYED OBJECTS AT THE CURRENT TIME
//*************************************************************************************************************
global proc jh_getCKeyObjs()
{
int $sliderVal = `currentTime -q`; //Get the current timeslider value
string $objects[] = `ls -dagObjects`; //Create an array with all dag objects in the scene

select -cl; //Clear selection
for ($i=0; $i < `size $objects`; $i++) //For each object in the $objects array
{
//If the objects has keyframe values at the current time, toggle-select it
if(`keyframe -time $sliderVal -query -keyframeCount $objects[$i]` != 0)
{
print ($objects[$i] + " ");
select -tgl $objects[$i];
}
}
}

//*************************************************************************************************************
// GET ALL KEYED OBJECTS
//*************************************************************************************************************
global proc jh_getKeyObjs()
{
string $objects[] = `ls -dagObjects`; //Create an array with all dag objects in the scene

select -cl; //Clear selection
for ($i=0; $i < `size $objects`; $i++) //For each object in the $objects array
{
//If the objects has keyframe values at the current time, toggle-select it
if(`keyframe -query -keyframeCount $objects[$i]` != 0)
{
print ($objects[$i] + " ");
select -tgl $objects[$i];
}
}
}

jh_getKeyObjs;

RedNine
10-18-2010, 09:20 AM
I've added a time management class to the Red9Studio pack that's in testing at the moment, a suite of tools aimed initially at the animator/tech animator. The Time node will allow you to offset the entire scene by X - thats all animation, audio, timelines and clips, looking at putting support for render settings in that too. It also has a selected only mode, so if you select a clip, a couple of audio nodes and a load of transforms, it'll work through them all and offset as appropriate.

If you want to give it a try, drop me a mail and I'll add you to the Alpha list.

Red

thebrianproject
10-18-2010, 03:08 PM
Wow. Thanks for the help everyone! I'm gonna check some of these out right now.

CGTalk Moderation
10-18-2010, 03:08 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.