On Wed, Oct 5, 2016 at 5:59 PM, Marcus Ottosson <[email protected]>
wrote:

> 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.
>

Oh... I find an example in the Maya 2017 workspace Python doc:
http://help.autodesk.com/cloudhelp/2017/CHS/Maya-Tech-Docs/CommandsPython/workspace.html

Maybe try using the event flag:

workspaceChangedID = cmds.scriptJob( event = ["workspaceChanged",
workspaceChangedCallback] )



> from maya import cmds
> cmds.scriptJob(conditionTrue=["workspaceChanged", 
> "cmds.warning('changed')"])# RuntimeError: Could not find condition or event 
> named "workspaceChanged" #
>
> ​
>
> On 5 October 2016 at 16:19, Nicolas Chaverou <[email protected]>
> wrote:
>
>> Hey,
>>
>> Kinda tricky but if you check the setProject.mel, it looks like the
>> workspace is changed pretty heavily
>> You may want to use a scriptJob on the workspaceChanged event and in the
>> callback, compare the value of the optionVar RecentProjectsList (which is
>> touched by addRecentProject.mel)
>>
>> Else overriding proc sp_workAfterOpeningProject(string
>> $projectLocation). But that's a bit dirty and dependant on your Maya
>> version...
>>
>> My 2cts
>>
>> ---
>> [image: Nicolas Chaverou - Golaem Crowd Product Manager - Golaem SA]
>>
>> +33 (0)2 99 27 21 44
>> http://www.golaem.com
>>
>> On Wed, Oct 5, 2016 at 10:43 AM, Mahmoodreza Aarabi <[email protected]>
>> wrote:
>>
>>> This is for setting project, but i think it have callback too, i didn't
>>> check that though. or scriptJob.
>>>
>>> On Wed, Oct 5, 2016 at 12:09 PM, Mahmoodreza Aarabi <[email protected]>
>>> wrote:
>>>
>>>> hey man
>>>> i did this and it works fine for me
>>>>
>>>> from maya import cmds, melimport 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
>>>> ​
>>>>
>>>> On Wed, Oct 5, 2016 at 11:28 AM, Marcus Ottosson <
>>>> [email protected]> wrote:
>>>>
>>>>> 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
>>>>> <http://download.autodesk.com/us/maya/2011help/API/class_m_scene_message.html>
>>>>> class is the closest thing I found, but it doesn’t provide anything 
>>>>> related
>>>>> to projects/workspaces.
>>>>>
>>>>> Any ideas?
>>>>>
>>>>> Thanks!
>>>>> ​
>>>>> --
>>>>> *Marcus Ottosson*
>>>>> [email protected]
>>>>>
>>>>> --
>>>>> 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/CAFRtmO
>>>>> Bo508CRtQCXwAi3%2BcPafk%2BT2P-6iP0dbZ421MKiHDy5g%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBo508CRtQCXwAi3%2BcPafk%2BT2P-6iP0dbZ421MKiHDy5g%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>>
>>>> Bests,
>>>> madoodia
>>>>
>>>
>>>
>>>
>>> --
>>>
>>>
>>> Bests,
>>> madoodia
>>>
>>> --
>>> 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/ms
>>> gid/python_inside_maya/CADvbQwJDGYy5_4KojYWO1S%3DX6eeduiu47R
>>> -6WfceovrY%3DDJrvA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CADvbQwJDGYy5_4KojYWO1S%3DX6eeduiu47R-6WfceovrY%3DDJrvA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> 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/ms
>> gid/python_inside_maya/CAFS5DCbE8GwfBaD1m%2B3%2B1HE1JA%
>> 3Dfkw8fyF8OgSaajmmy-_yWQQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAFS5DCbE8GwfBaD1m%2B3%2B1HE1JA%3Dfkw8fyF8OgSaajmmy-_yWQQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> *Marcus Ottosson*
> [email protected]
>
> --
> 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/CAFRtmOC6tapGXuxc%2Bpx4nZZVd9R-0TC0cxgL9N2w00%
> 3DMVPtBkg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOC6tapGXuxc%2Bpx4nZZVd9R-0TC0cxgL9N2w00%3DMVPtBkg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAFS5DCZJS1Dh5gObdjwUSefg5n4LVfCzbdtu%3DgOon0QMzTnwDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to