On Sat, Aug 25, 2018 at 11:27 AM kiteh <[email protected]> wrote: > Is there a way to check if the current maya session is 'new'? > > I have a tool created using PyQt, in which it stores the widgets inputs > using QSettings (asked this question previously). The settings and all > works out great, however I realized that if I launched a new maya session, > followed by relaunching my tool, the 'stored' settings is/ are being loaded. > > And hence, I would wanted to see if I can implemented in a way such that: > > - if user clicks on 'new scene' or open/ load a new file in the > current maya session > if my tool is relaunched, it will prompt a popup and > ask if User wants to load the 'old' settings or use default settings? > - if user launch a new maya session > open/ load a new file > launch > my tool, it should load in the default settings. > > Will this be too complicated to do so? I am hoping to implement in the > first point if possible. >
You can check cmds.file(query=True, sceneName=True) to see if the scene has been saved to a file yet. For more control, you can track the NewSceneOpened event using a scriptJob: http://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/CommandsPython/scriptJob.html#flaglistEvents Or using the API to to track specified scene events: http://help.autodesk.com/view/MAYAUL/2016/ENU/?guid=__cpp_ref_class_m_scene_message_html This would allow you to handle the first point. If you tracked the new scene event, you could switch a OptionVar bool back and forth between your event handler and your UI launch. > > Many thanks in advance! > > -- > 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/027560d6-b26d-4407-9329-1c019808ea93%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/027560d6-b26d-4407-9329-1c019808ea93%40googlegroups.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/CAPGFgA3PuxSCN%3Dai-BpLmr6uco0sREqfRCmvywHPfwnWOSovFA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
