Home Technical Talk

Maya mel script - problem selecting specific edges/faces on new created objects

polycounter lvl 12
Offline / Send Message
Hupie polycounter lvl 12
hey there,

I'm back again with another problem I'm having which I cannot find an answer for on the Internet so I need your help again.. I'm trying to create a little script to help me creating simple symetrical objects by creating a mirrored base object.

But I'm stuck on not being able to select certain edges to do operations on. I have the feeling I cannot do what I want because MEL scripting is not object orientated,  but how can I select faces/edges on objects stored in variables?

string $newcube[] = `polyCube -w 10 -h 10 -d 10 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;  // create new cube<br>objectMoveCommand;<br>select -r $newcube[0].e[1];  //trying to select specific edge, how do i do this?<br>SelectEdgeRingSp;<br>ConnectComponents; //connect middle edges<br>select -r $newcube[0].f[0:3] $newcube[0].f[5] ;<br>doDelete;  //delete faces on one side of cube<br>duplicatePreset(1,0,1,0,0,0,0,0,0,0,0,0,0,0,-1,1,1); //duplicate special to create instanced mirror copy


Replies

  • Klaudio2U
    Offline / Send Message
    Klaudio2U polycounter lvl 8
    It not like this:
       select -r $newcube[0].e[1];
    Like this: 
       select -r ($newcube[0] + ".e[1]"); 

    And this for faces later:
    select -r ($newcube[0] + ".f[0:3]") ($newcube[0] + ".f[5]");


  • Hupie
    Offline / Send Message
    Hupie polycounter lvl 12
    Perfect! That's just what i needed. Here is the full working script:

    string $newcube[] = `polyCube -w 10 -h 10 -d 10 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;<br>objectMoveCommand;<br>select -r ($newcube[0] + ".e[1]"); <br>SelectEdgeRingSp;<br>ConnectComponents;<br>select -r ($newcube[0] + ".f[0:3]") ($newcube[0] + ".f[5]");<br>doDelete;<br>select -r $newcube[0];<br>duplicatePreset(1,0,1,0,0,0,0,0,0,0,0,0,0,0,-1,1,1);


  • Klaudio2U
    Offline / Send Message
    Klaudio2U polycounter lvl 8
    I would probably do maybe something like this with a bit less code. It doesn't really matter since both do the job and the script is small so it's not a matter of performance or something....but here it is if you find it useful. 

    string $newcube[] = `polyCube -w 10 -h 10 -d 10 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
    polySplit -sma 180 -ep 0 0.5 -ep 3 0.5 -ep 2 0.5 -ep 1 0.5 -ep 0 0.5 ($newcube[0] + ".e[1]");
    delete ($newcube[0] + ".f[5:9]");
    instance $newcube[0]; 
    scale -r -1 1 1;
Sign In or Register to comment.