the curve
command takes an argument with the flag p
(for 'points'). So a simple linear curve from 0,0,0 to 1,0,0 looks like
import maya.cmds as cmds
cmds.curve( p=[(0,0,0), (1,0,0)], d = 1)
and a degree-3 nurbs curve might look like
cmds.curve( p=[(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9)], d=3 )
Your script will have to convert the asc points to XYZ values. If you are reading these yourself from a text file you'll have to the use standard python open command to open and read from a file. If you already have locators or other physical objects in your scene you can get their positions with the xform
command. This will get the position of an object named 'locator_name_goes_here' as an XYZ tuple.
loc_pos = cmds.xform('locator_name_goes_here', q=True, t=True, ws=True)
So.to run a curve through a bunch of points you would collect all of their positions in a big list and then pass that whole list to the curve command's p
flag:
# assuming all locators or objects are selected in order
locator_positions = []
for each_locator in cmds.ls(sl=True):
locator_positions.append (cmds.xform(each_locator, q=True, t=True, ws=True)
cmds.curve(p=locator_positions, d=3)