PDA

View Full Version : Selected vertex on mesh using python


yellowFattyBean
06-21-2012, 09:08 PM
Hi,

I just need to know how to get the vertex information which has been selected on a mesh.

Thanks

zoharl
06-22-2012, 12:29 AM
import pymel as pm

pm.select('pCube1.vtx[0]')
pm.ls(sl=1)[0].getPosition()


EDIT: Thanks, I changed mc to pm.

no-name-party
06-22-2012, 05:35 AM
You should replace "mc" with "pm" and it should work.

djx
06-22-2012, 01:27 PM
You didnt say what vertex info you were interested in.
zoharl demonstrated how to get some position info, but that would only be its preTransform position, meaning not taking into account the transforms that may be on the mesh or its heirarchy.

Anyway, here's a more general answer.
Use the nice pymel method for getting the selected vert
v = pm.selected()[0]
Then use dir() to get a list of methods you can use to extract vertex info
dir(v)
You can use help() to see what parameters may be available
help(v.getPosition)
Then you could get various info...
v.getPosition(space='world')
v.getUV()
v.numConnectedEdges()


david

CGTalk Moderation
06-22-2012, 01:27 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.