Rao Rao - 2 years ago 88
Python Question

How to list the vertices over a selected edge in Maya via Python

I have a scenario, where I need to snap an

Object B
over the vertices of a selected edge of
Object A
.
I need to know, how to list all the vertices of a selected polyObject edge in a sequence, so that I can duplicate and snap the objects to required vertices based on my requirement. Like snap to every alternate vertex.

Your suggestions are so valuable to me.

Thanks in advance.

Answer Source

This is a MEL version:

polyCube -sx 1 -sy 1 -sz 1 ;
select -r pCube1.e[7] ;
PolySelectConvert 3 ;
select -d pCube1.e[7] ;
$allComponents = `ls -selection` ;
print ( $allComponents ) ;

// print ( $allComponents[0] ) ;
// print ( $allComponents[1] ) ;

This is a Python version:

import maya.cmds as mc

mc.polyCube( sx=1, sy=1, sz=1 )
mc.select( 'pCube1.e[7]' )
mc.select( mc.polyListComponentConversion( tv=True ) ) 
allComponents = mc.ls( sl=True )
print( allComponents )

# print( allComponents[0] )
# print( allComponents[1] )
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download