PDA

View Full Version : list objectsets


FraserRobertson
09-20-2010, 08:42 PM
hey people

just a simple problem that i can't solve is "only" listing the objectSets that show up in the DAG, all the standard ways like ls(-et "objectSet") lists all objects sets in the scene, deformer etc.

The DAG and relationship editor can list these objectSets by them selfs so must be some way to list them with MEL

Any help would be great thanks!

NaughtyNathan
09-21-2010, 01:08 PM
it seems that the sets that show up in the outliner are not "usedBy" anything. If you check if the .usedBy attribute is connected to anything (I've done it cheaply by getting the attr size here), it's false for the sets that show up in the outliner, and true for those that don't (i.e. deformers, etc..).
I can't guarentee this is absolutely water-tight across the board, but it seems to be valid as far as I've tested...

getAttr -s tweakSet1.usedBy;
// Result: 1 //
getAttr -s ffd1Set.usedBy;
// Result: 1 //

getAttr -s defaultObjectSet.usedBy;
// Result: 0 //
getAttr -s quickSelectSet.usedBy;
// Result: 0 //
:nathaN

cyrus3v
09-22-2010, 02:24 PM
Well I have a similar situation. However in my case I tried to list only the mesh's but I can get any output.

I search on the net and find a cool tutorial about MEL and there they use the following mel line:


ls -sl -type "mesh";
// Result: pSphereShape1 //


But when I tried this I get nothing. Anyone knows why?

NaughtyNathan
09-22-2010, 03:17 PM
because likely you have no MESHES selected Ciro, only transforms.

If you want to list the selected objects, but based on their shape type you can use the -dag flag (alwasy use -ni too when dealing with -dag and "mesh"):

ls -sl -type "mesh" -dag -ni;:nathaN

cyrus3v
09-22-2010, 03:50 PM
NaughtyNathan you are awesome dude :applause:

I didn't realize that and I complete forgot that little detail that make all the diference. Seriously thanks =D

FraserRobertson
09-22-2010, 10:34 PM
thanks NaughtyNathan, but sadly is listed all these these collectionsets and other rubish stuff.

what I did find thoe is that object sets have api class (don't know much about them) but the one i am looking for is "kSet"

I tried this
string $objectSets = `itemFilter -bt "kSet" `;


lsThroughFilter $objectSets


this should work as it does with any other filter type, even if i "echo all" I can see that it passes only the object sets, but when I "lsThroughFilter"it's stored everything it search instead!

Any ideas?

NaughtyNathan
09-23-2010, 10:11 AM
do you have an example of a set that doesn't show up in the outliner but still fails the .usedBy test? (and a way for me to replicate it!)

Have you tried looking in the Relationship Editor MEL script to see if there's anything relevent in that?

what are you ultimately attempting to do anyway?

:nathaN

FraserRobertson
09-23-2010, 09:47 PM
hey, all i want to do is list all object sets in the DAG, so i can empty them all
array = maya.cmds.ls(et='objectSet')

for each in array:
if not maya.cmds.getAttr( (each + ".usedBy") , s=True):
print each

this lists the "objectSet", but also "ComponentList" what ever that is?

and I looked in the realsionship editor it used "setFilterScript" that led me back to maya filter which breaks with "kset" well doesn't output correctly

rahulsg2901
09-24-2010, 06:49 AM
As I understand by u r post that u want to list all objectSets that not empty so here a code for that

import maya.cmds as cmds

array = cmds.ls(et="objectSet")

for each in array:
getSet = cmds.sets (each, q=True, s=True)
if (getSet == 1):
print each
Correct me if I wrong

CGTalk Moderation
09-24-2010, 06:49 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.