Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Script to Add Shelf?
  RSS 2.0 ATOM  

Script to Add Shelf?
Rate this thread
 
53676
 
Permlink of this thread  
avatar
  • wesm
  • Posted: 25 March 2011 09:14 AM
  • Location: Louisville Kentucky
  • Total Posts: 204
  • Joined: 22 August 2006 01:27 PM

Hey,

I’m trying to write a script that will create a shelf with a single button. Here’s the code I have.

addNewShelfTab "MyNewShelf";

string $scriptsDirectory = `internalVar -usd`;
string $imagePath "\""+$scriptsDirectory+"\uiIMage.png\"";


shelfButton -annotation "Open UI" -image1 $imagePath -command "cmUI";

This works, however it adds two buttons that fire the same command. Also, the image isn’t being set. I tried to capture the userScriptDirectory in a variable and use this as the path to the image, but it doesn’t seem to work when supply -image1 with a variable.

Is there a better way to handle this?

Thanks,

Wes



Wes McDermott | 3D Artist | Author
http://the3dninja.com
http://the3dninja.com/blog

Replies: 0
avatar

I don’t have all your answers, but when I have used the shelfButton command, the -image flags were followed with a filename.extension only, and if the named image file is in an icon directory (either the one in your user prefs or the one in the Program Files folder) it will be located and used for your button.

I never had two buttons added from one invocation of the command, perhaps that is a hiccup from the -image flag not finding the name you used. You might try fixing that and testing again.

<* Wes *>



Replies: 1
/userdata/avatar/g4b0qfa63_Ninjatar.png

Thanks much : ) This actually helped. I placed the icon file in the user script directory/prefs/icons and just used the “name.extension” route and this worked perfectly.

Thanks!

Wes

Author: wesm

Replied: 28 March 2011 10:08 AM