Home Coding, Scripting, Shaders

Mel how to remove faces from current selection or array.

polycount sponsor
Offline / Send Message
malcolm polycount sponsor
I've got some faces selected on multiple objects through a script and I need to only select the faces from the object with a certain name, is there a way to remove from my selection or remove from my array in Mel? I was thinking the name of the object would be enough to identify which faces I want, but I can't figure out how to isolate those faces in Mel.

Replies

  • PolyHertz
    Offline / Send Message
    PolyHertz polycount lvl 666
    You can deselect faces in mel like this:
    select -d "pSphere1.f[218]"
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    I need to select a bunch of faces without knowing the exact numbers or names, basically I need to use part of the name and remove from the array. It looks like the match command is the place to start to match the name and try to remove them that way, but I'm still trying to figure out what the code would look like. I have the name of the object faces I want to keep in the array, just not sure how to filter my list and only select the faces that have that keyword in them.
  • PolyHertz
    Offline / Send Message
    PolyHertz polycount lvl 666
    If you use an asterisk symbol at the start/end of part of a name while selecting it'll use all names that start/end with those few letters. So instead of using pSphere1 we could use just the first few letters like such:
    select -d "pSp*.f[218]"
    or the last few letters:
    select -d "*ere1.f[218]"
    or just some of the middle letters:
    select -d "*here*.f[218]"

    As for not knowing the face numbers, do you mean you don't know how to get them from the existing string values? If so, don't use match for that (it'll fail if your object name has numbers in it), use tokenize instead:
    string $buffer[];
    tokenize "pSphere1.f[238]" "[:]" $buffer; //returns values to $buffer, index is element 1 as a string
    $theIndex = (int)$buffer[1];
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    I tried wildcards before getting stuck, but they didn't help because the faces could be on similarly named objects sphere1 sphere2. I haven't learned the tokenize stuff yet, that one's still above my head. I was able to get some help from my friend and we solved it with match like this. After I get the selection of all the faces it matches the $ObjectName and discards anything that doesn't have that name so I'm left with just the faces on the one object I care about. Ideally I would've never selected any additional faces to start with, but that wasn't an option given how the script works based on the user selection.

    string $AllSelectedFaces[] = `ls -fl -sl`;
    string $FilteredList[];
       
    for ($Item in $AllSelectedFaces)
        {
            string $NameMatch = `match $ObjectName[0] $Item`;
            if ($NameMatch == $ObjectName[0])    
            {        
                int $Index = (size($FilteredList));
                $FilteredList[$Index] = $Item;
            }
        }

Sign In or Register to comment.