I rewrite my code again, will this be any better?
By the way, I am still getting the part where my UI closes itself if it
found an invalid file
class ReadObjCloud():
""" read in vertex data from nuke 3d camera track """
def __init__(self, objPath):
try:
fileHandle = open(objPath,"r")
self.fileHandle = fileHandle
filePath = os.path.basename(fileHandle.name)
fileName = os.path.splitext(filePath)[0]
for char in fileHandle.readline()[0]:
if char.startswith("v"):
self.processLine()
# Selects all the imported locators, grouped and
transformed it
cmds.select(camSel[0] + "_locator*")
objGroup = cmds.group(n=("pointCloud_" + fileName))
cmds.xform(os=True, piv=(0, 0, 0))
cmds.scale(0.01, 0.01, 0.01)
cmds.delete(constructionHistory=True)
cmds.select(objGroup, camSel[0], add=True)
cmds.group(n="cameraTrack")
cmds.scale(10, 10, 10)
else:
self.noProcess()
except:
sys.stderr.write( "Failed to read file information\n")
raise
def processLine(self):
for line in self.fileHandle:
brokenString = string.split(line)
# Creation of locators and they are named with the prefix of
the imported camera
cmds.spaceLocator(name = camSel[0] + "_locator", absolute=True,
position=(\
float(brokenString[1])*100\
, float(brokenString[2])*100\
, float(brokenString[3])*100))
cmds.CenterPivot()
cmds.scale(0.5, 0.5, 0.5)
self.fileHandle.close()
def noProcess(self):
print "INVALID - Re-import again!!!"
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/091119de-fb86-451b-9162-9fe93ef592a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.