I am still having some trouble where my UI just closes when it is hitting
upon a warning where the UI should still be present for users to go back
and change some stuff.
In the following are three functions:
- chkBox : when enabled, it will also enables the textfield. So if the
textfield is blank, it will prompt a warning else it will carry on.
- readFileIn : the function for the Creation button in my UI, so
supposedly if everything is working fine and dandy, it should creates the
locator and group it else it will halt any if the obj parse is wrong.
- ReadObjCloud : parses the information of the obj file. So if the first
character is not V, it will prompts and Invalid warning. But this portion
seems to be the one giving me the most problem, as while it is able to
differentiate whether there are V characters in the first character, the ui
closes on me instead of the user going back to the ui and reimport a
working obj file...
Even though it seems to be 'working', I have also got the following error
in my editor:
#
# Error: Please import in a relevant Point Cloud Obj file
# Traceback (most recent call last):
# File "/user_data/test/chan.py", line 202, in readFileIn
# ReadObjCloud(self.finalObjPath)
# File "//user_data/test/chan.py", line 261, in __init__
# raise Exception( "Please import in a relevant Point Cloud Obj file\n")
# Exception: Please import in a relevant Point Cloud Obj file #
This is my code, and I think it is happening somewhere in either of the
three functions but I am unable to figure it out the hell of me.
class CustomNodeTranslator(OpenMayaMPx.MPxFileTranslator):
...
...
def chkBox(self):
importCloudCheck = cmds.checkBox(self.cloudCheckbox, query=True,
value=True)
finalObjPath = cmds.textField(self.waveFileAddress, query=True, text
=True)
if(importCloudCheck == 1):
if finalObjPath != "":
ReadObjCloud(finalObjPath)
return True
else:
return False
else:
print ("Importing in Camera only")
return True
def readFileIn(self, *args):
if self.chkBox():
chanRotationOrder = cmds.optionMenuGrp(self.rotationOrderControl
, value=True, query=True)
self.importTheChan = ChanFileImporter(chanRotationOrder)
try:
for line in self.fileHandle:
self.processLine(line)
self.fileHandle.close()
self.closeWindow()
except:
sys.stderr.write( "Failed to read file information\n")
raise
else:
cmds.warning("Input a valid Point Cloud Path or checked off the
Import option ")
class ReadObjCloud():
def __init__(self, objPath):
fileHandle = open(objPath,"r")
filePath = os.path.basename(fileHandle.name)
fileName = os.path.splitext(filePath)[0]
print fileHandle.readline()[0]
if fileHandle.readline()[0] == "v":
for line in fileHandle:
brokenString = string.split(line)
cmds.spaceLocator(name = "camera1_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)
fileHandle.close()
cmds.select("camera1_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, "camera1, add=True)
cmds.group(n="cameraTrack")
cmds.scale(10, 10, 10)
else:
raise Exception( "Please import in a relevant Point Cloud Obj
file\n")
--
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/ab8ff867-ca94-4e61-8a51-6b1722fe350a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.