Home Coding, Scripting, Shaders

Impossible to select random edge - MEL

polycounter lvl 5
Offline / Send Message
Pinned
jayantbhatt007 polycounter lvl 5

Hi someone told me that It is impossible to select any random edge if we are in edge mode i.e we have to select that edge manually we cannot do it through script.

see the screenshot I want to select that edge. Any command to do that? SEE THE ATTACHMENT

Replies

  • PolyHertz
    Offline / Send Message
    PolyHertz polycount lvl 666
    What? That's nonsense, of course you can make selections through scripts.
    For example, this would select edges 0-10 on the mesh named "pSphere1":

    select -r "pSphere1.e[0:10]" ;

    You just need to get the name of the mesh you want to make the selection on, the index numbers of the edges you want to select, and combine them into a string.
    To get selected objects names you would use ( `ls -sl -o -long`; ) or for all mesh objects in the scene you could use ( `ls -g -o`; ).
    To get how many edges there are in a mesh use ( polyEvaluate -e "meshName"; ).
    Then just use the rand command to get a random value within the number of edges that are in the mesh.
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    global proc rsSelectRandEdge()
    {
    string $rsSl[] = `ls -sl`;
    int $rsNoOfEdge[] = `polyEvaluate -e $rsSl[0]`;
    int $rsRand = rand(0,$rsNoOfEdge[0]);
    select -r ($rsSl[0]+".e["+$rsRand+"]");
    }
    rsSelectRandEdge;
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    Someone other guy helped me in this but this script is only selecting  the end of the cylinder  ( if it is closed) not the side edge as I mentioned in the screenshot. It looks like only selecting the 0 degree angle.
  • PolyHertz
    Offline / Send Message
    PolyHertz polycount lvl 666
    The above posted script should select the edge randomly, is that not what you wanted? If you want to select a specific loop then will need to know what you're trying to achieve since there are so many ways to go about it. You could for example select the edge closest to the camera/mouse, world/local position, normal vector, etc.
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    yes this script is selecting the edge randomly but I want to select the edge as it is mention in the screenshot with the red color. Is it possible?
Sign In or Register to comment.