MEL Script Help: Select All Keyed Objects


#1

Original Post
where @shcmack said,

“You can choose between selecting all keyed objects at the current frame, or all keyed objects in the entire scene.”

I’ve pasted this in Maya 2019 but it’s not showing a window which should be as script contain window command.
This one is written in 2010 so maybe it requires an update. But Idk scripting so If anyone help to make it working in 2019… It’d be very helpful.
Thank You.
PS: or You can just divide it into two parts without implementing a window, (Single Click for “All Keyed Objects” & Double Click for “All Keyed Objects on Current Frame”) Window is not necessary here.

//*************************************************************************************************************
// 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 "Selects all objects that has a keyframe at the current time";
  button -label "Select keyed objects at current time" -c jh_getCKeyObjs -bgc 0.15 0.75 0.09;
  text -label "Selects all objects that has keyframes in the entire scene " ;
  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;