View Full Version : How do you cancel an export?

03 March 2008, 04:01 PM
Is it possible to have a callback script run preExport, and then if the script should fail, or if a certain event results allow the script to cancel the Export?

so to clarify...using callbacks.addScript "Export_Script()" #preExport

if Export_Script() returns "cancel" can i then Cancel the Export?

Or as soon as you click the Export in max, there's no way to stop it from Exporting?

03 March 2008, 05:38 PM
One method (maybe the only method) is to use dialogMonitorOps to check when the dialog opens, and uiAccessor to close it if your script determines that it should be aborted

03 March 2008, 05:53 PM
quick test script...

-- change this variable to set whether the file export dialog should be closed
doExport = false

callbacks.removescripts id:#exportTest
fn closeExportDialog = (
local _hwnd = dialogMonitorOps.getWindowHandle()
local _title = UIAccessor.getWindowText _hwnd
if (_title == "Select File to Export") then (
UIAccessor.closeDialog _hwnd
dialogMonitorOps.unregisterNotification id:#closeExportDialog
dialogMonitorOps.enabled = false
else ( true )

fn exportTest = (
if (not doExport) then (
dialogMonitorOps.enabled = true
dialogMonitorOps.registerNotification closeExportDialog id:#closeExportDialog

callbacks.addScript #preExport "exportTest()" id:#exportTest

03 March 2008, 05:55 PM
Awesome man....thanks for you help :)

03 March 2008, 05:59 PM
alternatively you could use fileExport and export the file manually, but I'm presuming you're using the callback for a reason :) Good luck!

CGTalk Moderation
03 March 2008, 05:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.