Thanks for your suggestion, Mike. Trying to keep code as independent as possible, so would rather work directly with the data instead.
Got some help with this elsewhere, but posting here if anyones interested.
import maya.cmds as cmds
def create_curve(data):
crvs = list()
steps = data[2]
for i in range(data[0]):
pts = zip(*data[1][:-1])[sum(steps[:i]):sum(steps[:i + 1])]
if data[5][i]: # closed curve
pts.append(pts[0])
crvs.append(cmds.curve(degree=1, p=pts))
#combining curves
node = cmds.group(empty=True)
for crv in crvs:
shp = cmds.listRelatives(crv,shapes=True)
cmds.parent(shp, node, r=True, s=True)
cmds.delete(crv)
# data sample comes from rigicon/config/Main.py
data = (3, ((-2.7755575615628914e-17, -2.7755575615628914e-17, -0.5, 0.5, -2.7755575615628914e-17, -2.7755575615628914e-17), (0.0, 0.0, 0.0, 0.0, 0.5, -0.5), (0.5, -0.5, 3.0616171314629196e-17, -3.0616171314629196e-17, -3.0616171314629196e-17, 3.0616171314629196e-17), (1.0, 1.0, 1.0, 1.0, 1.0, 1.0)), (2, 2, 2), ((0.0, 0.0, 0.0), (1.0, 1.0, 1.0)), (2, 2, 2), (False, False, False), (1, 1, 1), (1, 1, 1))
create_curve(data)
This is for a Maya port of the rigicon framework, being developed by Cesar Saez (GitHub - csaez/rigicon: Curve/icon library for Softimage.).