Hello all. I have a python script I had done for an exercise a while back that I need help with. I got up to the point of taking a text file and doing an output in the script editor but as far as graphing it in Maya using nurbs curves I’m not sure how to go about it.
I heard it has something to do with longitudinal and latitudinal ranges or something like that but I never have seen a code example to go by. I don’t mind posting the script and the .txt file but I would be grateful if someone could help me since this has been on my to do list for a while.
Thanks in advance,
Jon
import maya.cmds as mc
def movieGenre():
#import re
defaultDirectory = mc.workspace(query = True, rootDirectory = True)
if mc.optionVar(exists = "dialogDefaultDirectory"):
defaultDirectory = mc.optionVar(query = "dialogDefaultDirectory")
userFile = mc.fileDialog(mode = 0, directoryMask = ("%s/*.txt" % defaultDirectory))
if not len(userFile):
print "# No file selected."
return
print "# The user selected %s" % userFile
mc.optionVar(stringValue = ("dialogDefaultDirectory",
userFile[0:userFile.rfind("/")]) )
file = open(userFile, "r")
#pattern = re.compile('-*\d+\.\d+')
points = []
curves = []
genres = []
genreCounts = []
# converts data to set up for curves.
lineCount = 0
for line in file:
lineCount = lineCount + 1
line = line.strip()
lineSplit = line.split()
if len(line):
if lineCount == 1:
genres = line.split()[1:]
for genre in genres:
genreCounts.append([])
else:
i = 0
for count in lineSplit[1:]:
genreCounts[i].append(float(count))
i = i + 1
# make curves from the data stored in genreCounts
# make the curve, record its name and prepare for another curve
curve = mc.curve(name = "curveData", degree = 3, point = points)
curves.append(curve)
points = []
# curve = mc.curve(name = "curveData", degree = 1, point = points)
# curves.append(curve)
print "# Curves made from %s:" % (userFile[userFile.rfind("/") + 1:])
for curve in curves:
print "# %s" % curve
file.close()