CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 01-29-2013, 09:12 PM   #1
Daemonecles
Wearer of Ninja Pants
 
Daemonecles's Avatar
portfolio
Andres Weber
CG Generalist
MPC
New York, USA
 
Join Date: Jul 2007
Posts: 346
Send a message via AIM to Daemonecles
Unhappy Dynamic Shelf Loading

Hey guys!

Just had a question that I'm having problems googling/searching on the forum...I'm trying to dynamically load a shelf so that it always appears in its most updated state on the user's computer. Here's what I've figured out so far:
I am using Maya.env and added a line

Code:
$MAYA_STARTUP_SCRIPT_PATH = (shared directory where I have a startup.mel file)


The startup.mel file says:
Code:
//check to see if shelf exists string $install_shelfName = "andres"; string $install_shelfPath = "/usr/people/andres-w/andresShelfMaster/shelf_andres.mel"; int $install_shelfExists = `layout -q -ex $install_shelfName`; if ($install_shelfExists == 1){ print "Deleting existing Andres shelf\n"; deleteUI -layout $install_shelfName; } //add shelf print "Adding Andres Shelf\n"; loadNewShelf $install_shelfPath;


So this doesn't quite work to remove the old shelf cleanly...and using the command deleteShelfTab requires hitting OK and doesn't work either. Any help would be most appreciated! Also I'm probably doing this completely wrong so...thanks for pointing me in the right direction ahead of time!

Background: Can't use userSetup.mel since it's getting overridden by our pipeline in some way that I'm not sure of...
__________________
MPC NYC
Andres Weber | CG Generalist
434 Broadway, 9th Floor, New York City, 10013
GChat AndresMWeber
www.moving-picture.com

Last edited by Daemonecles : 01-29-2013 at 09:16 PM.
 
Old 01-29-2013, 09:59 PM   #2
Daemonecles
Wearer of Ninja Pants
 
Daemonecles's Avatar
portfolio
Andres Weber
CG Generalist
MPC
New York, USA
 
Join Date: Jul 2007
Posts: 346
Send a message via AIM to Daemonecles
So I fixed the issue. Took the command deleteShelfTab from the maya install and removed all confirmDialog mentions and now the shelf deletes properly (I think the other UI command doesn't do it cleanly because it leaves the .deleted file).

New Issue: The loadNewShelf command, if done at startup seems to load a shelf that's blank. When I run the exact same code to delete and repopulate the shelf when maya is already running it works as intended...anyone know a workaround?
__________________
MPC NYC
Andres Weber | CG Generalist
434 Broadway, 9th Floor, New York City, 10013
GChat AndresMWeber
www.moving-picture.com
 
Old 01-29-2013, 10:08 PM   #3
zeroeffect
Code Junkie
portfolio
Chris Zurbrigg
Software Developer
Independent
Canada
 
Join Date: Jul 2005
Posts: 221
For the startup code, try wrapping it in an evalDeferred command.
 
Old 01-29-2013, 10:27 PM   #4
Daemonecles
Wearer of Ninja Pants
 
Daemonecles's Avatar
portfolio
Andres Weber
CG Generalist
MPC
New York, USA
 
Join Date: Jul 2007
Posts: 346
Send a message via AIM to Daemonecles
Exclamation

Thanks for the reply. Looks like using evalDeferred delays the creation of the shelf but messes up start up code:

Code:
// Error: file: /software/maya/2012.4.5/linux.centos5.x86_64/scripts/startup/shelf.mel line 81: Object 'andres' not found. //


Looks like this mel gets confused because our shelf doesn't exist at startup but for some reason Maya thinks it still was. Line 81 in that code is just trying to determine whether a shelf is unpopulated with buttons and populates it if it isn't.

Edit: Oh! You're the author of Charcoal Editor! I totally bought that awhile back. Thanks!
__________________
MPC NYC
Andres Weber | CG Generalist
434 Broadway, 9th Floor, New York City, 10013
GChat AndresMWeber
www.moving-picture.com

Last edited by Daemonecles : 01-29-2013 at 10:31 PM.
 
Old 01-29-2013, 10:57 PM   #5
doctorbob
Guy who does stuff
Chris Gardner
Sydney, Australia
 
Join Date: Aug 2002
Posts: 70
Hi Daemonecles,

I've been here before and have a few hints.

* if you're looking to update a shelf, don't try and delete the entire shelf. You end up with shelves that won't update properly, and general mysteriousness. Instead, delete all the buttons, but leave the shelf there. Then you can add the updated buttons.

* loading in new shelves from the disk: i use a method where you open up the shelf mel file and replace some stuff and eval it. python code here:
Code:
fReObj = re.search("(shelfButton.*\;[\r\n])", shelfContents, re.DOTALL) if fReObj: shelfBtnStr = fReObj.group(1) n = shelfBtnStr.replace('shelfButton', 'shelfButton\n -parent ' + shelfName) mel.eval(n)


that's all i got. it works pretty well once you get it going. best of luck.

cheers,
chrisg
 
Old 01-29-2013, 11:02 PM   #6
Daemonecles
Wearer of Ninja Pants
 
Daemonecles's Avatar
portfolio
Andres Weber
CG Generalist
MPC
New York, USA
 
Join Date: Jul 2007
Posts: 346
Send a message via AIM to Daemonecles
Thumbs up

Phew! I was looking for some good stuff like this! Thanks man, I'll test it out tomorrow but I'm sure it works.
__________________
MPC NYC
Andres Weber | CG Generalist
434 Broadway, 9th Floor, New York City, 10013
GChat AndresMWeber
www.moving-picture.com
 
Old 01-29-2013, 11:38 PM   #7
rgkovach123
Know-it-All
robert
austin, USA
 
Join Date: Nov 2006
Posts: 364
Here is some abstracted code I use to manage Shelves.
If you can put your Shelves in source control and update Maya's Shelve Directory, then you dont have to worry about the user altering the Shelf and saving a copy in the user folder. Since the shelf is write protected by source control, Maya will be unable to save it when exiting.
This makes updating shelves and ensuring everyone has the latest changes really easy.

Unfortunately, I dont have that luxurty currently, so i made these wrapper functions to manage updating the shelves for me. I used the same trick of leaving the shelf and clearing the buttons.


Code:
def createMyShelf(): shelfName = 'My_Shelf' test = cmds.shelfLayout(shelfName, ex=True) if test: # If the shelf already exists, clear the contents and re-add the buttons. newShelf = shelfName buttons = cmds.shelfLayout(newShelf, query=True, childArray=True) cmds.deleteUI(buttons, control=True) else: newShelf = mel.eval('addNewShelfTab %s' % shelfName) cmds.setParent(newShelf) # add buttons here


Code:
def removeShelf(): shelfName = 'My_Shelf' test = cmds.shelfLayout(shelfName, ex=True) if test: mel.eval('deleteShelfTab %s' % shelfName) gShelfTopLevel = mel.eval('$tmpVar=$gShelfTopLevel') cmds.saveAllShelves(gShelfTopLevel) else: return
 
Old 01-29-2013, 11:38 PM   #8
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:27 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.