Hi all,
I’m looking to run a snippet of Python when the user changes project.
For example, I’d like the string "Project was set!" to be printed when running this.
from maya import cmds
def on_setproject():
print("Project was set!")
cmds.workspace("C:/my/project", openWorkspace=True)
The MSceneMessage class is the closest thing I found, but it doesn’t provide anything related to projects/workspaces.
Any ideas?
Thanks!
hey man
i did this and it works fine for me
from maya import cmds, mel
import pymel.core as pm
workspace_path = os.path.normpath("your/path")
pm.mel.setProject(workspace_path)
mel.eval("print \"Project set successfully\\n\";")
check it
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBo508CRtQCXwAi3%2BcPafk%2BT2P-6iP0dbZ421MKiHDy5g%40mail.gmail.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBo508CRtQCXwAi3%2BcPafk%2BT2P-6iP0dbZ421MKiHDy5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--Bests,madoodia
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CADvbQwJDGYy5_4KojYWO1S%3DX6eeduiu47R-6WfceovrY%3DDJrvA%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Thanks Mahmoodreza and Nicolas!
You may want to use a scriptJob on the workspaceChanged event
That sounds like just what I’m looking for, however I can’t find this event? I’m on Maya 2015, preferably I’d like it to work from 2013 and above.
from maya import cmds
cmds.scriptJob(conditionTrue=["workspaceChanged", "cmds.warning('changed')"])
# RuntimeError: Could not find condition or event named "workspaceChanged" #
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CADvbQwJDGYy5_4KojYWO1S%3DX6eeduiu47R-6WfceovrY%3DDJrvA%40mail.gmail.com.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFS5DCbE8GwfBaD1m%2B3%2B1HE1JA%3Dfkw8fyF8OgSaajmmy-_yWQQ%40mail.gmail.com.
Thanks Mahmoodreza and Nicolas!
You may want to use a scriptJob on the workspaceChanged event
That sounds like just what I’m looking for, however I can’t find this event? I’m on Maya 2015, preferably I’d like it to work from 2013 and above.
workspaceChangedID = cmds.scriptJob( event = ["workspaceChanged", workspaceChangedCallback] )
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFS5DCbE8GwfBaD1m%2B3%2B1HE1JA%3Dfkw8fyF8OgSaajmmy-_yWQQ%40mail.gmail.com.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOC6tapGXuxc%2Bpx4nZZVd9R-0TC0cxgL9N2w00%3DMVPtBkg%40mail.gmail.com.
That works!
from maya import cmds
def on_setproject():
print("Project was set!")
cmds.scriptJob(event=["workspaceChanged", on_setproject])
cmds.workspace("C:/my/project", openWorkspace=True)
In 2015 too! Thanks Nicolas!