Complex UV Layout in Maya
Over the last couple of years UV layout in Maya has changed for the better. In this course we're going to be taking a look at some of those changes as we UV map an entire character
# 1 26-07-2012 , 10:18 AM
Registered User
Join Date: Jan 2012
Posts: 43

Script request for sets management

Hello guys!
I was wondering how hard it would be to write two commands:

one would be "add current object(s) to set XX"
and the other "remove current object(s) from set XX"

thing is, I don't want to have to select the set I want to add/remove the object!
I would just like a variable set name inside the script that I could change manually to suit my needs.
That's because we have a number of Sets with pre defined names all over the place and we have to add/remove stuff all the time.
I know I can use the relationship editor or drag and drop blablablah, the key here is to GO FAST and don't interrupt workflow...
I'd make a marking menu with those commands with add/rem for all sets..

If a kind soul has the time to do this, I'd be ever so gratefull!

# 2 26-07-2012 , 02:50 PM
Registered User
Join Date: Jan 2012
Posts: 43
Ok I couldn't wait so I teached myself some python, that was super simple actually!


def add2Set():
selection = cmds.ls(sl=True)
myObject =selection[0]
cmds.sets( (myObject), add='SET01' )

but I couldn't get it to work inside a marking menu because it's python..
I tryed the python import command but then I get this error : # Error: NameError: global name 'cmds' is not defined #

What the eff?? script is working fine from a shelf...

Any ideas??

# 3 26-07-2012 , 02:53 PM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
This capability is already built in to maya (I am currently using maya 2012. Not sure how far back it goes). To access the set manager gui select...

windows > relationship editors > sets

This brings up a gui that will show you all your sets, what is in them, and has a + / - button to add and remove elements to and from selected sets.


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675
# 4 26-07-2012 , 03:00 PM
Registered User
Join Date: Jan 2012
Posts: 43
Ho man you didn't read my first post user added image

# 5 26-07-2012 , 03:05 PM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
Seriously? It takes to much time to simply put the set editor on the shelf and then

1. click the shelf button
2. click the + or - key

Really?

Oh well if you must have a script. Why not just echo all commands in the script editor and then using the set editor add a selection to a set and then open the script editor and using the code generated you can create your generalized script add. Then do the same thing for the - key.


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675
# 6 26-07-2012 , 03:24 PM
Registered User
Join Date: Jan 2012
Posts: 43
This is the first thing I tried, doesn't work. There's no clear command coming out of history like addtoSet and so forth..
But thanks for your kinda weirdly aggressive advice!

actually I have no idea what I'm doing, the script can be much simpler:

selection = cmds.ls(sl=True)
cmds.sets( (selection), add='SET01' )


Last edited by yoruneko; 26-07-2012 at 03:53 PM.
# 7 26-07-2012 , 05:13 PM
Registered User
Join Date: Jan 2012
Posts: 43
allright I got it.

the most tricky part was loading python from the marking menus. It wouldn't work because I didn't load maya.cmds in my .py now it's working, oh the glory...

Well, I pat myself on the back I guess!


Last edited by yoruneko; 26-07-2012 at 05:25 PM.
# 8 25-02-2017 , 06:30 PM
Registered User
Join Date: Oct 2016
Posts: 2
This script could be of use to you:
Set List

# 9 26-02-2017 , 11:29 PM
Jay's Avatar
Lead Modeler - Framestore
Join Date: Feb 2003
Location: UK
Posts: 6,287
You kids!! Nothing changes when 'speed' is of the essence

Yeah I agree with CTBram, call me old school but the reason the set editor is there is for that exact reason, having a script is a bit pretentious and is not always going to be an advantage when you need to do this type of work at a component level.

With a python command you will always need to have 'import maya cmds'

The set editor has been around since jesus, and its not going anywhere soon, I can tell you that

Jay

# 10 04-04-2017 , 08:39 AM
Registered User
Join Date: Apr 2017
Posts: 1

You kids!! Nothing changes when 'speed' is of the essence

Yeah I agree with CTBram, call me old school but the reason the set editor is there is for that exact reason, having a script is a bit pretentious and is not always going to be an advantage when you need to do this type of work at a component level.

With a python command you will always need to have 'import maya cmds'

The set editor has been around since jesus, and its not going anywhere soon, I can tell you that

Jay

Yes, all very well until you need to make 1000 relationship edits and then code becomes quite useful...

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads