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: