PDA

View Full Version : Iterate NURBS For Duplicate curve


CadOp
12-15-2012, 03:58 PM
Hello,

I have a nurbs surface that I want to run duplicatecurve on through python. When I click the button in maya it works by iterating through all the u parameters of the nurbs and duplicating the curve ( i can see in script editor). How can I do this in python? I was able to figure something out with a sphere I created, which i got the min and max value of the U param, then looped over the value and used the iterator as the u value index number, however when using a non conventional nurbs the u values are like: [0.02],[0.04]...[0.6].. etc.

How can I query/iterate through the nurbs to get the values so i can duplicate it.

min_v_val=cmds.getAttr( 'manipSurface.minValueU' )
max_v_val=cmds.getAttr( 'manipSurface.maxValueU' )

curve_v_id=min_v_val
i=0
cmds.select(clear=True)
curve_list=[]
while curve_v_id<max_v_val:
surfaceforcurve='manipSurface.u[%d]' % (curve_v_id)
cmds.duplicateCurve(surfaceforcurve,object=True, local=True, range=False,ch=False)
curve_v_id=curve_v_id+1
i=i+1


second question:

I am projecting the curves onto a surface and then need to group again. I am getting the underworld error as the projected curves are locked so I am duplicating them again. If I have them in a list (I added each projected curve to a list when creating it) how can I iterate through them, currently i have to type in the string as shown below because the list index says: 'baseSurface->' not 'baseSurfaceShape' ... Is there a better way of doing this?

to_dup='baseSurfaceShape->projectionCurve'+str(i)+'_'+str(j)
cmds.duplicateCurve(str(to_dup),object=True, local=True, range=False,ch=False)


Thanks!

Mat

CGTalk Moderation
12-15-2012, 03:58 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.