PDA

View Full Version : TextScrollList filter by type?


ginodauri
09-20-2008, 04:03 PM
hi

How to filter objects in TextScrollList by type?

I assume that can be done with nodeType command,but is there some "easier" way.

RyanT
09-20-2008, 06:54 PM
If you have a text scroll list you can just do this:

window myWin;
paneLayout;
textScrollList myList;
string $filteredNodes[] = `ls -type "mesh"`;
for($node in $filteredNodes)
textScrollList -e -append $node myList;

showWindow myWin;
window -e -wh 300 400 myWin;


-RyanT

ginodauri
09-20-2008, 08:09 PM
This command will get all meshes from scene,or i'm wrong?

I need nodeType from text scroll list.

I find solution for that with nodeType.

But i'm trying something that i'm not sure can work.

Simple,i have Tsl and have buttom for getting selected object in Tsl.

I have checkboxes(example polygon checkbox) ,and when i press checkBox i want to filter polygonal objects from Tls,and when unchecked i want to "revert" this action.
That is filtering objects types inside Tsl.

I hope this make sense :)

RyanT
09-20-2008, 10:50 PM
The command ls -type "type" will give you whatever type you ask for in the selected nodes. The command ls gives you the selection and type filters your selection. To get a specific node type type:

nodeType "nodeName";

So to do what your asking for you can do at least one of these ways:

#1
string $currentSel[] = `ls -sl`; //Store the current user selection
string $getList[] = `textScrollList -q -allItems myList`;
select $getList;
string $filterSel[] = `ls -type "mesh"`;
select $currentSel;
print $filterSel;

#2
string $getList[] = `textScrollList -q -allItems myList`;
string $filterSel[];
for( $item in $getList)
{
//Change the word transform with whatever type you are looking for
if(`nodeType $item` == "transform")
$filterSel[`size($filterSel)`] = $item;
}
print $filterSel;


I suppose there might be more ways to do it, but both ways work.

-RyanT

ginodauri
09-21-2008, 08:44 AM
I don't know if i don't understand something,but if i write something like this;


string $test1 [] = `ls -sl`; ///get current selection

select -cl; /////clear selection

select $test1; ///select stored selection

string $filter [] = ` ls -type "mesh" ` ; /////Than this command should filter meshes in that "test1" but i get all meshes from scene.

Buexe
09-21-2008, 09:08 AM
Actually you could combine the -sl and the type flag, but since you probably have the transform nodes selected, maya will return an empty list. So one would need to check which node of the current selection has a child of type mesh. Here is a very ugly hack, but it works just to illustrate how you could get the shapes. Writing a proc that wil check all this is prorbably more elegant than just to use brute force with the pickwalk command, anyway maybe this is more like what you are after:
select some meshes in the viewport and run

pickWalk -d down;
$objs = `ls -sl -type mesh`;
window ;
paneLayout;
$list = `textScrollList`;
for($node in $objs)
textScrollList -e -append $node $list;
showWindow ;

ewerybody
09-21-2008, 11:49 PM
but to not destroy the current selection you could also:

// list the mesh children of current selection and return the transforms:
string $meshTransforms[] = `listRelatives -p (listRelatives("-c","-type","mesh"))`;

Buexe
09-22-2008, 07:52 AM
// list the mesh children of current selection and return the transforms:
string $meshTransforms[] = `listRelatives -p (listRelatives("-c","-type","mesh"))`;

nice power move, ewerybody :thumbsup:

CGTalk Moderation
09-22-2008, 07:52 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.