Selecting Isoparms .u[*]/.v[*] in NURBs via Python


#1

Hi wizards!

I’m quite new to python :slight_smile: but I am fumbling along the way. I’ve been searching endlessly to find the solution to this problem with no avail. Hopefully this is a quick fix!

I simply want to select all of the .u[li] or .v[*] isoparm of a NURB and can’t seem to get it working correctly. The * asterix does not seem to give me the right output, it only select the beginning and ending of the isoparm and spits out something like .u[0:3] and I just can’t seem to expand that out properly either.
[/li]
So far my coding looks like this (ugly coding but…somewhat works):

selection = cmds.ls(selection = True, fl=1, sl=1)
for object in selection:
cmds.select(object + β€˜.v[0]’, object + β€˜.v[1]’, object + β€˜.v[2]’, object + β€˜.v[3]’, object + β€˜.v[4]’, object + β€˜.v[5]’, object + β€˜.v[6]’, object + β€˜.v[7]’, object + β€˜.v[8]’, object + β€˜.v[9]’, object + β€˜.v[10]’, object + β€˜.v[11]’, object + β€˜.v[12]’, object + β€˜.v[13]’, object + β€˜.v[14]’, object + β€˜.v[15]’, object + β€˜.v[16]’, object + β€˜.v[17]’, object + β€˜.v[18]’, object + β€˜.v[19]’, object + β€˜.v[20]’, object + β€˜.v[21]’, object + β€˜.v[22]’, object + β€˜.v[23]’, object + β€˜.v[24]’, object + β€˜.v[25]’,)

cmds.select section looks very very messy I know >.<; but it is the only way it can get it to work so far, but I’m sure there has to be an easier way to select the .u[] or .v[] that I’ve missed.

Any help will be super grateful!
Thank you!


#2

It could work this way if you don’t mind using pymel. Combining strings is a bit ugly and not very pythonic bit it works:

import pymel.core as pm
s = pm.ls(sl=True)
up = sh.numSpansInU()
vp = sh.numSpansInV()
sel = []
for u in range(up):
    sel.append(s[0] + ".u[" + str(u) + "]")
for v in range(vp):
    sel.append(s[0] + ".v[" + str(v) + "]")
pm.select(sel)


#3

Thanks so much Haggi! I will give this a go :slight_smile: