question

Mohamed Oumoumad avatar image
Mohamed Oumoumad asked ·

arnold through maya python inside nuke's interpreter

I'm trying to execute a maya python command from nuke, the command basically exports an object from a scene file. when I execute this script first time, it works fine, but when I execute it again a second time, I get an arnold error and nuke crashes.

Here is how the script looks like :

################################################################

import os
import subprocess
import nuke
import sys

os.environ["MAYA_LOCATION"] = "C:\Program Files\Autodesk\Maya2018"
os.environ["PYTHONHOME"]    = "C:\Program Files\Autodesk\Maya2018\Python"
os.environ["PATH"] = "C:\\Program Files\\Autodesk\\Maya2018\\bin;" + os.environ["PATH"]

sys.path.append("C:\Program Files\Autodesk\Maya2018\Python\lib\site-packages\setuptools-0.6c9-py2.6.egg")
sys.path.append("C:\Program Files\Autodesk\Maya2018\Python\lib\site-packages\pymel-1.0.0-py2.6.egg")
sys.path.append("C:\Program Files\Autodesk\Maya2018\Python\lib\site-packages\ipython-0.10.1-py2.6.egg")
sys.path.append("C:\Program Files\Autodesk\Maya2018\Python\lib\site-packages\ply-3.3-py2.6.egg")                         
sys.path.append("C:\Program Files\Autodesk\Maya2018\\bin\python26.zip")
sys.path.append("C:\Program Files\Autodesk\Maya2018\Python\DLLs")
sys.path.append("C:\Program Files\Autodesk\Maya2018\Python\lib")
sys.path.append("C:\Program Files\Autodesk\Maya2018\Python\lib\plat-win")
sys.path.append("C:\Program Files\Autodesk\Maya2018\Python\lib\lib-tk")
sys.path.append("C:\Program Files\Autodesk\Maya2018\\bin")
sys.path.append("C:\Program Files\Autodesk\Maya2018\Python")
sys.path.append("C:\Program Files\Autodesk\Maya2018\Python\lib\site-packages")
import maya.standalone
import maya.cmds as cmds

def getAbc(userSelectedFile,userSelectedObject,userStartFrame,userEndFrame):
	maya.standalone.initialize()
	# cmds.loadPlugin('mtoa')
	cmds.loadPlugin('AbcExport')
	cmds.file(new=True, force=True) 
	#open desired file
	sceneFile = userSelectedFile
	cmds.file( sceneFile, o=True)
	projectPath = sceneFile.split("02_SCENE")[0]
	cmds.workspace(projectPath, openWorkspace=True)
	#define variables
	selectedObj = userSelectedObject
	startFrame = userStartFrame
	endFrame = userEndFrame

	#get transform of the selected shape
	selectedTransform = cmds.listRelatives(selectedObj,parent=True, fullPath = True)[0]

	#het names without the | for windows os naming
	renamedFile = selectedObj.replace("|","_")
	#export to alumbic in the right place
	objectPath = cmds.workspace( q=True, rootDirectory = True) + '{}{}.{}'.format('01_ASSET/08_OBJECTS/',renamedFile,'abc')


	#create the directory if it doesn't exist
	dir_path = os.path.dirname(objectPath)
	if not os.path.exists(dir_path):
		os.makedirs(dir_path)

	#export to abc
	command = '-frameRange {} {} -uvWrite -worldSpace -dataFormat hdf -root {} -file {}'.format(startFrame, endFrame, selectedTransform, objectPath)
	cmds.AbcExport(j = command)
	print "seccessfully exported to :"
	cmds.file(new=True, force=True) 
	maya.standalone.uninitialize()
	return objectPath

The full error I get looks like this :

signal caught: error C0000005 -- access violation


****
* Arnold 5.4.0.0 [b7d9819c] windows icc-17.0.2 oiio-2.1.0 osl-1.11.0 vdb-4.0.0 clm-1.0.3.513 rlm-12.4.2 optix-6.0.0 2019/07/26 08:50:52
* CRASHED in memmove at 00:00:00
* signal caught: error C0000005 -- access violation
*
* backtrace:
*  0 0x00007ffa1fd547ee [ai           ]
*  1 0x00007ffa1fd53a8f [ai           ]
*  2 0x00007ffa9986fb5a [KERNELBASE   ] UnhandledExceptionFilter
*  3 0x00007ffa9c684ab2 [ntdll        ] memset
*  4 0x00007ffa9c66c676 [ntdll        ] _C_specific_handler
*  5 0x00007ffa9c68119f [ntdll        ] _chkstk
*  6 0x00007ffa9c64a229 [ntdll        ] RtlRaiseException
*  7 0x00007ffa9c67fe0e [ntdll        ] KiUserExceptionDispatcher
>> 8 0x00007ffa966ec387 [VCRUNTIME140 ] memmove
*  9 0x00007ffa49ac0108 [Foundation   ] Tarray::insertElement
* 10 0x00007ffa53184793 [CommandEngine] TcommandEngine::pushLanguageContext
* 11 0x00007ffa531d53bb [CommandEngine] TpythonInterpreter::dispatchMayaCommand
* 12 0x000000006232dc76 [python27     ] PyCFunction_Call
* 13 0x0000000062390c51 [python27     ] PyEval_GetFuncDesc
* 14 0x000000006238e4cb [python27     ] PyEval_EvalFrameEx
* 15 0x0000000062390e06 [python27     ] PyEval_GetFuncDesc
* 16 0x0000000062390cc0 [python27     ] PyEval_GetFuncDesc
* 17 0x000000006238e4cb [python27     ] PyEval_EvalFrameEx
* 18 0x0000000062390e06 [python27     ] PyEval_GetFuncDesc
* 19 0x0000000062390cc0 [python27     ] PyEval_GetFuncDesc
* 20 0x000000006238e4cb [python27     ] PyEval_EvalFrameEx
* 21 0x000000006238f85d [python27     ] PyEval_EvalCodeEx
* 22 0x00000000623c9dd0 [python27     ] PyRun_FileExFlags
* 23 0x00000000623c9c20 [python27     ] PyRun_StringFlags
* 24 0x00007ffa503cecde [nuke-11.2.3  ] initnuke
* 25 0x00007ffa503cc038 [nuke-11.2.3  ] initnuke
* 26 0x00007ffa4ff52e0d [nuke-11.2.3  ] Nuke::NodePanelI::operator=
* 27 0x00007ffa4ff52996 [nuke-11.2.3  ] Nuke::NodePanelI::operator=
* 28 0x00007ffa5075a679 [nuke-11.2.3  ] Nuke::ReduceGPUOps::gpuEngine_GL_end_recursive
* 29 0x000000006277b632 [Qt5Core      ] QMetaObject::activate
* 30 0x0000000062b17472 [Qt5Widgets   ] QAction::activate
* 31 0x0000000062c7b0a8 [Qt5Widgets   ] QMenu::actionGeometry
* 32 0x0000000062c7af06 [Qt5Widgets   ] QMenu::actionGeometry
* 33 0x0000000062c7fca9 [Qt5Widgets   ] QMenu::mouseReleaseEvent
* 34 0x0000000062b5233a [Qt5Widgets   ] QWidget::event
* 35 0x0000000062c7c5d4 [Qt5Widgets   ] QMenu::event
* 36 0x0000000062b280b2 [Qt5Widgets   ] QApplicationPrivate::notify_helper
* 37 0x0000000062b25d3e [Qt5Widgets   ] QApplication::notify
* 38 0x00007ffa4be7db1a [studio-11.2.3] SetCrashHandlerCallback
* 39 0x000000006275ae29 [Qt5Core      ] QCoreApplication::notifyInternal2
* 40 0x0000000062b294c0 [Qt5Widgets   ] QApplicationPrivate::sendMouseEvent
* 41 0x0000000062b7a025 [Qt5Widgets   ] QSizePolicy::QSizePolicy
* 42 0x0000000062b78545 [Qt5Widgets   ] QSizePolicy::QSizePolicy
* 43 0x0000000062b280b2 [Qt5Widgets   ] QApplicationPrivate::notify_helper
* 44 0x0000000062b26fc7 [Qt5Widgets   ] QApplication::notify
* 45 0x00007ffa4be7d52c [studio-11.2.3] SetCrashHandlerCallback
* 46 0x000000006275ae29 [Qt5Core      ] QCoreApplication::notifyInternal2
* 47 0x00007ffa547c14a3 [Qt5Gui       ] QGuiApplicationPrivate::processMouseEvent
* 48 0x00007ffa547a785b [Qt5Gui       ] QWindowSystemInterface::sendWindowSystemEvents
* 49 0x00000000627a2ec8 [Qt5Core      ] QEventDispatcherWin32::processEvents
* 50 0x00007ffa9c27681d [USER32       ] CallWindowProcW
* 51 0x00007ffa9c276212 [USER32       ] DispatchMessageW
* 52 0x00000000627a25f6 [Qt5Core      ] QEventDispatcherWin32::processEvents
* 53 0x00007ffa6ec98019 [qwindows     ] qt_plugin_query_metadata
* 54 0x0000000062757553 [Qt5Core      ] QEventLoop::exec
* 55 0x0000000062759bb7 [Qt5Core      ] QCoreApplication::exec
* 56 0x00007ffa4c2d8e28 [studio-11.2.3] SetCrashHandlerCallback
* 57 0x00007ff746f315fd [Nuke11.2     ]
* 58 0x00007ff746f31527 [Nuke11.2     ]
* 59 0x00007ff746f66735 [Nuke11.2     ]
* 60 0x00007ffa9c427bd4 [KERNEL32     ] BaseThreadInitThunk
* 61 0x00007ffa9c64ce71 [ntdll        ] RtlUserThreadStart
*
* loaded modules:
*    0x00007ffa1fa00000  ai
*    0x00007ffa99770000  KERNELBASE
*    0x00007ffa9c5e0000  ntdll
*    0x00007ffa966e0000  VCRUNTIME140
*    0x00007ffa49a00000  Foundation
*    0x00007ffa53160000  CommandEngine
*    0x0000000062240000  python27
*    0x00007ffa4fe20000  nuke-11.2.3
*    0x00000000625a0000  Qt5Core
*    0x0000000062b10000  Qt5Widgets
*    0x00007ffa4b890000  studio-11.2.3
*    0x00007ffa54790000  Qt5Gui
*    0x00007ffa9c260000  USER32
*    0x00007ffa6ec40000  qwindows
*    0x00007ff746f30000  Nuke11.2
*    0x00007ffa9c410000  KERNEL32
****
Stack trace:
  ntdll.dll!RtlRaiseException
  ntdll.dll!KiUserExceptionDispatcher
  VCRUNTIME140.dll!memmove
  Foundation.dll!Tarray::insertElement
  CommandEngine.dll!TcommandEngine::pushLanguageContext
  CommandEngine.dll!TpythonInterpreter::dispatchMayaCommand
  python27.dll!PyCFunction_Call
  python27.dll!PyEval_GetFuncDesc
  python27.dll!PyEval_EvalFrameEx
  python27.dll!PyEval_GetFuncDesc
  python27.dll!PyEval_GetFuncDesc
  python27.dll!PyEval_EvalFrameEx
  python27.dll!PyEval_GetFuncDesc
  python27.dll!PyEval_GetFuncDesc
  python27.dll!PyEval_EvalFrameEx
  python27.dll!PyEval_EvalCodeEx
  python27.dll!PyRun_FileExFlags
  python27.dll!PyRun_StringFlags
  nuke-11.2.3.dll!initnuke
  nuke-11.2.3.dll!initnuke
  nuke-11.2.3.dll!Nuke::NodePanelI::operator=
  nuke-11.2.3.dll!Nuke::NodePanelI::operator=
  nuke-11.2.3.dll!Nuke::ReduceGPUOps::gpuEngine_GL_end_recursive
  Qt5Core.dll!QMetaObject::activate
  Qt5Widgets.dll!QAction::activate
  Qt5Widgets.dll!QMenu::actionGeometry
  Qt5Widgets.dll!QMenu::actionGeometry
  Qt5Widgets.dll!QMenu::mouseReleaseEvent
  Qt5Widgets.dll!QWidget::event
  Qt5Widgets.dll!QMenu::event
  Qt5Widgets.dll!QApplicationPrivate::notify_helper
  Qt5Widgets.dll!QApplication::notify
  studio-11.2.3.dll!SetCrashHandlerCallback
  Qt5Core.dll!QCoreApplication::notifyInternal2
  Qt5Widgets.dll!QApplicationPrivate::sendMouseEvent
  Qt5Widgets.dll!QSizePolicy::QSizePolicy
  Qt5Widgets.dll!QSizePolicy::QSizePolicy
  Qt5Widgets.dll!QApplicationPrivate::notify_helper
  Qt5Widgets.dll!QApplication::notify
  studio-11.2.3.dll!SetCrashHandlerCallback
arnoldmtoapythonnukecommand line
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Stephen Blair avatar image
Stephen Blair answered ·

If you're seeing the Arnold crash report, then Arnold is still loaded in memory.
Turn off Auto Load and restart

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Mohamed Oumoumad avatar image
Mohamed Oumoumad answered ·

Even when I force unloading mtoa plugin, I still get the crash that's catched by arnold, so it's strange for me to think that this is completely independent of arnold

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Mohamed Oumoumad avatar image
Mohamed Oumoumad answered ·

I wonder if there is a way to just "close" the maya.standalone and unload everything including mtoa, that way things would be like if the script wasn't executed, so it would work again fine like first time.

When I do cmds.unloadplugin("mtoa") I get an error that says mtoa can't be unloaded cause it's still in use, even after I do the maya.standalone.uninitialize().

Maybe there is something I missed regarding usage of maya python.

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Stephen Blair avatar image
Stephen Blair answered ·

The Arnold crash handler may catch the crash, but Arnold isn't causing the crash.

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.