PDA

View Full Version : query or return true if selection type is 'edge'


biorhythm
11-03-2007, 07:56 PM
Hello,

Im curious howto query the type of polygon components in a current selection?

Purpose being, I want to run a procedure and/or loop if the current selection(or first element in array) is a poly edge, so how do i go about this? So far I figure the following will suffice, although it seems somewhat of a hack and wonder if a method with more finesse exists? Perhaps a 'type' to use with 'ls -type' or even a command to query/list selected component types...


{
string $selectedEdges[] = `filterExpand -sm 32` ;
if(size($selectedEdges)!=1)
error "please select 1 polygon edge" ;

"else, run procedure"
}

also, as a less definitive approach, the following:

{
string $selectedEdges [] = `ls -sl -fl -type float3`;
if(size($selectedEdges)!=1)
error "please select 1 polygon edge" ;

"else, run procedure"
}

However as 'float3' refers to edge and vertex(possibly more?) this is could be cumbersome.

So far I've looked at threads such this, but don't seem to get the logic, in the following its the " if (`match "\.vtx" $selection[$i]` == "\.vtx") " line that gets me...

http://forums.cgsociety.org/showthread.php?f=89&t=111233&highlight=determine+selection+type


Any ideas or feedback are greatly welcomed, and as always, thanks in advance

Julz

:)

biorhythm
11-03-2007, 09:04 PM
Ok,

So after reading the Open Maya Toolbox script, OMT_to_selectLoop.mel (by Jakob Welner), I find that using 'filterExpand -sm' can be well fuctional. By using a combination of 'filterExpand -sm' with an if/else statement and 'undoInfo -swf', it is possible to determine the selected component by deducing the selection. Once again, this to me this seems a lot of work to find type. Is their not an easier way to simply list selected components?

I guess by now Im probably showing my limited knowledge of MEL, nevertheless, any help and advice is greatly appreciated.

Thanks once again,

Julz.

:)

thematt
11-04-2007, 08:56 AM
yep there is easier,

here is what I used

{
string $sel[]=`ls -fl -sl`;
if(`match "e\\[" $sel[0]`=="e[")
print "edge";
else
print "noEdge";
}

cheers

biorhythm
11-04-2007, 07:10 PM
very nice, thanks for the tip, works a charm!

julz

:)

thematt
11-05-2007, 07:58 AM
glad it helped..

cheers

hibigibees
11-05-2007, 05:30 PM
hi, your first approch was cool too:

{

string $tmp[] = `ls -sl`;
if(! size(`filterExpand -sm 32 $tmp[0] `) ) error "first selected item is not an edge";
else print "first selected item is an edge";

}

CGTalk Moderation
11-05-2007, 05:30 PM
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.