Move NURBS points

Move NURBS points

Anonymous
Not applicable
601 Views
1 Reply
Message 1 of 2

Move NURBS points

Anonymous
Not applicable

Okay, I've figured out how to create a NURBS circle and find out the relative positions of the control points.

import maya.cmds as cmds
myObjName = "nurbsCircle1"
myObj = cmds.circle( nr = (0, 1, 0), c = (0, 0, 0), sw = 360, r = 1, d = 3, ut = 0, tol = 0.1, s = 8, ch = 1, n = myObjName)

numCVs = cmds.getAttr( myObjName + "Shape.spans")
numDegs = cmds.getAttr( myObjName + ".degree" )

for i in range (0, numCVs):
  cv = myObjName + ".cv" + "["  + str(i) + "]"
  print str(cmds.pointPosition( cv ))

# [0.783611624891225, 4.798237340988468e-17, -0.7836116248912238]
# [-1.2643170607829326e-16, 6.785732323110913e-17, -1.108194187554388]
# [-0.7836116248912243, 4.798237340988471e-17, -0.7836116248912243]
# [-1.108194187554388, 1.966335461618786e-32, -3.21126950723723e-16]
# [-0.7836116248912245, -4.7982373409884694e-17, 0.783611624891224]
# [-3.3392053635905195e-16, -6.785732323110915e-17, 1.1081941875543881]
# [0.7836116248912238, -4.798237340988472e-17, 0.7836116248912244]
# [1.108194187554388, -3.644630067904792e-32, 5.952132599280585e-16]

The question is now that I have each point position, how do I move each point?
Cheers
0 Likes
Accepted solutions (1)
602 Views
1 Reply
Reply (1)
Message 2 of 2

chaneyx
Advocate
Advocate
Accepted solution

I believe xform will do the job. I am not in front of Maya, but I believe this is the general idea : 

 

MEL 

xform -ws -t x y z curve1.cv[4] 

 

PYTHON

cmds.xform('curve1' + ".cv" + str([i]), t= (vertPos[0], vertPos[1], vertPos[2]), a=True, ws=True)

 

OR if you are doing something elaborate, you would make an MPxDeformer plugin via python or C++