XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : Mesh Selection

11-17-2006, 05:25 PM
I need some MEL scripting help!

I need to check whether the user has a polygon mesh selected, then complete an if/else
statement with this info.

If, the user has a polygon mesh selected => execute script...
(it must be selected at object level, no faces etc)

Else, Dialogue warning window appears "Please Select Mesh".

I have declared a selection variable at the start of my script...
How do I use this variable inside a procedure later on??


11-17-2006, 06:28 PM
$theMeshes=`ls -sl -type mesh`;This will give you a list of all poly meshes selected. The mesh nodes must be selected, not the transform node containing the mesh. $theSelection=`ls -sl`;
$theMeshes=`listRelatives -allDescendents -type mesh $s`;This will give you all the poly meshes that are descendents of the selected nodes. It's probably the result you want.if(size(&theMeshes))
// do stuff
// error message

11-17-2006, 07:38 PM
There is an even easier way to do it:

$sel = `filterExpand -sm 12`;

//stuff to do if polygon meshes are selected
} esle {
//stuff to do if polygon meshes aren't selected

ok so maybe it's only one less line of code, but that still means less typing.

11-20-2006, 09:54 AM
...it's always so easy when you see it written!

CGTalk Moderation
11-20-2006, 09:54 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.