Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Mel script, is it possible to query if faces are selected on child geometry?

Mel script, is it possible to query if faces are selected on child geometry?

malcolm_341
Collaborator Collaborator
649 Views
0 Replies
Message 1 of 1

Mel script, is it possible to query if faces are selected on child geometry?

malcolm_341
Collaborator
Collaborator

I have a tricky problem. I need to create an error message in this condition and can't figure it out.

I have two spheres.

SphereB is parented under SphereA.

I select SphereA and enter face component mode.

But then, I select faces on SphereB.

I'd like to print true if any faces are selected on SphereB, and print false if faces are only selected on SphereA.

I've tried this for a day and I can't quite get it, here's what I have. Any ideas on how to get this to work?

 

global string $m341_dupef_SelectedFaces[];
global string $m341_dupef_Child_ObjectName[];
$m341_dupef_SelectedFaces = `ls -fl -sl`;
toggleSelMode;
toggleSelMode;
selectMode -object;
$errorSelectedObjs = `ls -sl`;

//Error if first selected object has child and faces are selected on child object instead of first selected object
//Check if object has child

string $m341_dupef_Child_ObjectName[] = `listRelatives -type transform`;
$size_child_ObjectName = `size $m341_dupef_Child_ObjectName`;

if ($size_child_ObjectName > 0)
{
     //Counter for the for loop
     int $counter = 0;
     //Loop through each face in the array and if it matches child object name error because it's on the wrong object
     for ($item in $m341_dupef_SelectedFaces)
{

string $nameMatch = `match $m341_dupef_Child_ObjectName[$counter] $item`;
if ($nameMatch == $m341_dupef_Child_ObjectName[$counter])
{
     error "Doesn't work if object has children, unparent children first";
}

$counter = $counter + 1;

0 Likes
650 Views
0 Replies
Replies (0)