import maya.cmds as cmds
def reloadScene():
recentFiles = []
curFile = cmds.file(query = True, location = True)
if (curFile == "unknown") :
if cmds.optionVar( exists = 'RecentFilesList' ):
recentFiles = cmds.optionVar( query = 'RecentFilesList' )
if cmds.confirmDialog(title = 'Reload Scene', message = ('Reload Last Opened Scene?\n\n' + recentFiles[len(recentFiles)-1]), button = ['Cancel','OK'], defaultButton = 'OK', cancelButton = 'Cancel', dismissString = 'Cancel' ):
cmds.file( str(recentFiles[len(recentFiles)-1]), force = True, open = True)
print "Opening Last Recent File - ", recentFiles[len(recentFiles)-1]
else:
cmds.warning("No recent files found!")
else:
if cmds.confirmDialog(title = 'Reload Scene', message = ('Reload Current Scene?\n\n'), button = ['Cancel','OK'], defaultButton = 'OK', cancelButton = 'Cancel', dismissString = 'Cancel' ):
curFileLoc = cmds.file(query = True, location = True)
cmds.file( curFileLoc , force = True, open = True)
print "Re-Opening current file - ", curFileLoc
the curFile variables, my dialog is not popping up and I have a very strong inkling that I have gotten the mel part -
if(`file -q -loc` == "unknown") wrong
However, should I omit it, I am unable to get the second dialog working- Reload Current Scene working.
Any pointers are greatly appreciated!
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/687fc019-66ef-4e67-bce2-e95dbeaab015%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
|
This email is free from viruses and malware because avast! Antivirus protection is active. |
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/549998FA.4090509%40gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/687fc019-66ef-4e67-bce2-e95dbeaab015%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/687fc019-66ef-4e67-bce2-e95dbeaab015%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
![]()
This email is free from viruses and malware because avast! Antivirus protection is active.
--
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 python_inside_maya+unsub...@googlegroups.com.
Hi
I can't check out too much in depth since I'm on my phone. But you definitely should not be using the return statement in your try except since that will immediately return from your function and not execute any more code. Also, is a try except necessary here? Does an optionvar call raise an exception? I actually can't confirm atm.
A few nitpicky things... remove the spacing in your params of function calls:
foo( var = "hello" )
should really be
foo(var= "hello")
Also, I find it easier to read code when it tries to return early, instead of having nested indented if statements. So if you have a check that needs to pass before continuing then do something like
if x != 1:
return
Instead of
if x == 1:
if y == 2:
if z == 3:
print True
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fa42c21b-7f51-4483-b70a-bda207796a76%40googlegroups.com.