Selecting Vertices Sharing Two Edges

Screen_shot_2011-04-08_at_1

Here’s a Python snippet that selects vertices sharing only two edges (using maya.cmds as mc):

With the mesh object selected,

obj = mc.ls(sl=True)[0]
vertCount = mc.polyEvaluate(obj, v=True)
vertList = [‘{0}.vtx[{1}]’.format(obj,vert) for vert in range(vertCount) if len(mc.polyInfo(‘{0}.vtx[{1}]’.format(obj,vert), ve=1)[0].split(‘:’)[1].split()) == 2]
mc.select(vertList)

The if statement containing the polyInfo command does the filtering by counting the number of edges around the queried vertex. Unfortunately this returns a line of values in a string, so I had to split it a couple times to retrieve the edges count. For example, vertex 302 of ‘polySurface’ is shared by the edges 506, 489, 484, and 485:

mc.polyInfo(‘polySurface.vtx[302]’, ve=1)[0]
# Result: u’VERTEX 302: 506 489 484 485 n’ #


UPDATE: A vertex sharing two edges is called ‘winged’. Here’s another way to select winged vertices using PyMEL (as pm)…

obj = pm.ls(sl=True)[0]
vertList = [obj.verts[v] for v in range(len(obj.verts)) if len(obj.verts[v].connectedEdges()) == 2]
pm.select(vertList)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s