Hello,
I started working on this two days ago because it is something I have always wanted to make for myself. I never even looked but I am sure there is a tool out there like this. I am creating a tool where you will input a MEL curve command and it will spit out the python version. So far I have completed the conversion part and am now working on implementing a GUI that will store all your conversions for later, more convenient use. This is my conversion code, any ideas on simplifying it or just flat out redundant code corrections would be greatly appreciated. I will be updating this as I truck along.
#import needed modules
import maya.cmds as cmds
#declare Variables
nCurve = 'curve -d 1 -p 4 0 -1 -p 4 0 0 -p 5 0 0 -p 5 0 -1 -p 4 0 -1 -p 4 1 -1 -p 5 1 -1 -p 5 0 -1 -p 5 0 0 -p 5 1 0 -p 5 1 -1 -p 4 1 -1 -p 4 1 0 -p 5 1 0 -p 5 0 0 -p 4 0 0 -p 4 1 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 ;'
pPoints = []
cDegree = 'd='
cPoints = 'p=('
cKnots = 'k=('
#Create Base variable lists
degree = nCurve.split('-p', 1)
points = degree[1].split('-p')
knots = points[-1].split('-k')
points.remove(points[-1])
points.append(knots[0])
degree.remove(degree[1])
knots.remove(knots[0])
hKnots = knots[-1].rstrip(';')
knots.remove(knots[-1])
knots.append(hKnots)
#Create final degree string
nDegree = degree[0].rstrip()
fDegree = nDegree[-1]
fDegree = cDegree + fDegree
#Create final points string
for o in points:
n = o.strip()
nVal = n.replace(' ', ',')
fVal = '(' + nVal + ')'
pPoints.append(fVal)
for o in pPoints:
cPoints = cPoints + o + ','
fPoints = cPoints.rstrip(',')
fPoints = fPoints + ')'
#Create final knots string
for o in knots:
i = o.strip()
cKnots = cKnots + i + ','
fKnots = cKnots.rstrip(',')
fKnots = fKnots + ')'
#concatinate it all together
final = 'cmds.curve('+fDegree+', '+fPoints+', '+ fKnots+')'
print final