Home Technical Talk

Python Maya get closest edge to a given postition

dlz
dlz
polycounter lvl 4
Offline / Send Message
Pinned
dlz polycounter lvl 4
Anyone knows an easy way to get the closest edge to a given position? i already know a way to do this for closest faces and closest vertices with the node closestPointOnMesh but this only returns faces and vertices.

Replies

  • throttlekitty
    Options
    Offline / Send Message
    Convert edge to verts first then closestPointOnMesh? If you're looking for the edge center, you could average the result of both verts.
  • dlz
    Options
    Offline / Send Message
    dlz polycounter lvl 4
    But i dont know the name of the edge when the script is running, this is a part of a long script and i only have a position, and by that position i want to get an edge depending on the faces of a plane (subdivided) i created. i dont understand completely how closestPointOnMesh cause its not very documented but if there are more than one component at the same distance of a given position it choses only one of them, and can only return a vertex and a face.
    I solved the problem in my script but i dont think it will work in other cases. 
    Anyways thanks for the answer!
  • throttlekitty
    Options
    Offline / Send Message
    Sorry, I had a total brain fart there and got something backward there.

    I'm curious what you came up with if you don't mind sharing?
  • dlz
    Options
    Offline / Send Message
    dlz polycounter lvl 4
    https://www.youtube.com/watch?v=c4PwTkahMnA&feature=youtu.be
    This is it, now it works fine with any subdivision axis of the cylinder :) 
    I did this cause i think it's an interesting tool to have, (i've seen already a more complex script about that for 3dmax) and because in the proces i learn a lot of python, that was a new language to me.
Sign In or Register to comment.