PDA

View Full Version : [MEL] retrieve script editor outputs w/o log file turned on


berniebernie
04-15-2009, 10:21 AM
hello fellow cgtalkers

does anyone know a way to retrieve the contents of the top script editor panel ? I can't seem to find a way to do it from the commands ref manual.

I'd like to retrieve the last lines printed and check wether a setAttr was called (and it seems like a simple enough task)

edit: without the log file turned on, as mentioned in the title

thank you !

Saving up a new thread, does anyone have a quick sample of how to make a right-click menu from a shelf button ? I'm using popupMenu but I have to click on the shelf button before having access to the right click menu, which defeats the whole purpose ? I will post my code later.

Robert Bateman
04-15-2009, 10:47 AM
In the API you can use MCommandMessage. Not sure if it's possible to do it in mel, but if it's possible it will be one of the script job events (since that's normally how the Message classes are exposed to mel).

claydough
04-15-2009, 04:54 PM
hello fellow cgtalkers

does anyone have a quick sample of how to make a right-click menu from a shelf button ? I'm using popupMenu but I have to click on the shelf button before having access to the right click menu, which defeats the whole purpose ? I will post my code later.

source the shelfButton at startup with userSetup.mel

popUp menu code:


/*cly_shelfButtonPopUpTemplate.mel
cly_reflectionMenus.mel v.2.0.3
Roger Klado was here
because no one else will do it fer me
February 19, 2009 ( some symmetry utilities )
RogerKlado@gmail.com ( Klado/Claydough/cly_ )
a template for shelfButton popUpMenus
*/


global proc cly_shelfButtonPopUpTemplate( string $parent )
{
if ( `control -exists $parent` ) { // then create a popupMenu for menuItems // control UI are received with a unique long pathname
string $uniqueMenu = "cly_reflectMenu_"+ $parent;
// unique-ness is established by using UI's path. Assure UI name is legal by stripping "|"
while ( $uniqueMenu != ( $uniqueMenu = `substitute "|" $uniqueMenu "_"` ) ); // thanks to Byran Ewert! mel How-to #34
if ( `popupMenu -exists $uniqueMenu` )
deleteUI $uniqueMenu;

popupMenu
-parent $parent
-button 3
-postMenuCommand ( "cly_dynMenuItems \""+ $parent+ "\"" )
-allowOptionBoxes true
$uniqueMenu;
}
}
global proc cly_dynMenuItems( string $parent )
{
if ( `control -exists $parent` ) {
//
string $uniqueMenu = "cly_reflectMenu_"+ $parent;
// unique-ness is established by using UI's path. Assure UI name is legal by stripping "|"
while ( $uniqueMenu != ( $uniqueMenu = `substitute "|" $uniqueMenu "_"` ) ); // thanks to Byran Ewert! mel How-to #34
//
popupMenu -e -deleteAllItems $uniqueMenu;
setParent -menu $uniqueMenu;
// static popup menu items begin
//______________________________________________________________________
menuItem
-label "Hello"
-command "print \"Hello Werld\\n\"";
menuItem -divider true;
menuItem
-label "GoodBye"
-command "print \"GoodBye Werld\\n\"";
}
}

// end


create shelf whose annotaion will be used to restore popUpMenus

global proc cly_shelfButtonPopUpSetUpTemplate()
{
global string $gShelfTopLevel;
if (`tabLayout -exists $gShelfTopLevel`){
shelfButton
-parent ($gShelfTopLevel + "|" + `tabLayout -q -st $gShelfTopLevel`)
-image "commandButton.xpm"
-annotation "hello goodbye"
-label "hello goodbye"
-command ( "print \"Hello\\n\"" )
;// end button
}

string $controlUI[] = `lsUI -long -ctl`;
for ( $b in $controlUI ) {
// query fer annotation instead of label ( users change labels )
string $annoCheck = `control -q -annotation $b`;
if ( $annoCheck == "hello goodbye" ) {
cly_shelfButtonPopUpTemplate $b;
}
}
}
// end

append following code to restore popUpMenus at startUp

// supporting userSetup.mel annotaion search source code
// add the following lines to your userSetup.mel for cly_shelfButtonPopUpTemplate shelfButton pop-Up menu rebuild:
// if no userSetup.mel exists in your scriptDirectory... then simply rename this file to userSetup.mel and place it in your scripts directory
{
string $controlUI[] = `lsUI -long -ctl`;
for ( $b in $controlUI ) {
// query fer annotation instead of label ( users change labels )
string $annoCheck = `control -q -annotation $b`;
if ( $annoCheck == "hello goodbye" ) {
string $popUpMenuChildren[] = `control -q -popupMenuArray $b`;
if ( size( $popUpMenuChildren ) )
deleteUI $popUpMenuChildren;
cly_reflectionMenus $b;
}
}
}
//end

In depth l popUpMenu shelfButton example:
cly_pivotReflectionModeling.mel (http://rogerklado.web.officelive.com/cly_pivotReflectionModeling.aspx)

http://farm4.static.flickr.com/3575/3284079475_86a4c44ac6.jpg

http://forums.cgsociety.org/showthread.php?t=730836

berniebernie
04-15-2009, 08:04 PM
thank you for your time !

claydough
04-16-2009, 06:12 AM
made a copyPaste mistake to the userSetUp code ( wrong proc at the end )

for the template it should be:


// supporting userSetup.mel annotaion search source code

// add the following lines to your userSetup.mel for cly_shelfButtonPopUpTemplate shelfButton pop-Up menu rebuild:
// if no userSetup.mel exists in your scriptDirectory... then simply rename this file to userSetup.mel and place it in your scripts directory
{
string $controlUI[] = `lsUI -long -ctl`;
for ( $b in $controlUI ) {
// query fer annotation instead of label ( users change labels )
string $annoCheck = `control -q -annotation $b`;
if ( $annoCheck == "hello goodbye" ) {
string $popUpMenuChildren[] = `control -q -popupMenuArray $b`;
if ( size( $popUpMenuChildren ) )
deleteUI $popUpMenuChildren;
cly_shelfButtonPopUpTemplate $b;
}
}
}
//end

CGTalk Moderation
04-16-2009, 06:12 AM
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.