Skip to content

Instantly share code, notes, and snippets.

@tpoveda
Last active January 21, 2021 02:30
Show Gist options
  • Save tpoveda/eb668ca1bd7504123e37a0d461d3ffd2 to your computer and use it in GitHub Desktop.
Save tpoveda/eb668ca1bd7504123e37a0d461d3ffd2 to your computer and use it in GitHub Desktop.
PyMxs - Forces the creation of a new 3ds Max scene without prompting any UI
def force_new_scene():
"""
Forces the creation of a new 3ds Max scene without prompting any UI
"""
mxs_function = """fn mf = (
local windowHandle = DialogMonitorOPS.GetWindowHandle()
if (windowHandle != 0) then (
UIAccessor.PressButtonByName windowHandle "Do&n't Save"
)
return true
)
"""
rt.execute('mf={}'.format(mxs_function))
rt.DialogMonitorOPS.unRegisterNotification(id=rt.Name('forceNewFile'))
rt.DialogMonitorOPS.registerNotification(rt.mf, id=rt.Name('forceNewFile'))
rt.DialogMonitorOPS.enabled = True
rt.actionMan.executeAction(0, '16') # new file macro action
rt.DialogMonitorOPS.unRegisterNotification(id=rt.Name('forceNewFile'))
rt.DialogMonitorOPS.enabled = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment