So we've created a pipeline tool (as a plugin) where we have a Python callback (om.MSceneMessage.kAfterNew) set up to trigger a function every time a new scene file is created. The main goal with this is to set up the new scene with the same default variables across all workstations, like using VRay as the current renderer and have the default resolution and other settings configured.
Let's say we fire up Maya (2016) and at the end of the startup it creates a new, empty, scene. This will trigger the callback function and all is good until we get to the last part where we have the VRay specific code. Here it produces the following error message:
However; afterwards when I do a manual "File -> New Scene" it works perfectly. This implies to me that the VRay plugin hasn't finished loading when the new scene is created by Maya - so my first thought was to add a delay loop to give it time to finish loading. To avoid waiting too long we check for VRay availability every second.
I've tried different ways to test, here are the main ones:
I've also tried the different commands as mel - even doing "rehash;" before each new run-through of the loop. Splitting out the code to a separate Python module and doing import/reload didn't help either.
I've also skipped the delay loop check entirely and done a "pause" for 30 seconds en then tried to run my commands, but that doesn't help either.
My working theory is that all scripts/plugins triggered by the startup sequence in Maya (userSetup.mel) only have access to a snapshot of the Maya internals - and that this snapshot doesn't get updated until after we have finished loading Maya and all startup scripts - which makes it too late to do what we need to do. I may very well be wrong about this, but every test I have done so far fails and I'm not sure about what to try next. I've even tried the ugly hack of having my script create another new scene (after the first one) - but this fails as well.
Any suggestions or ideas are greatly appreciated!
Cheers!
-atle
Let's say we fire up Maya (2016) and at the end of the startup it creates a new, empty, scene. This will trigger the callback function and all is good until we get to the last part where we have the VRay specific code. Here it produces the following error message:
Code:
// Error: line 1: The renderer vray is not registered yet. //
I've tried different ways to test, here are the main ones:
Code:
mel.eval('pluginInfo -q -l "vrayformaya"') # will always say True since VRay are marked as active - even though it hasn't finished loading yet cmds.renderer( 'vray', exists = True ) # always returns False even though we check every second for 4 minutes before giving up. This should be plenty of time.
I've also skipped the delay loop check entirely and done a "pause" for 30 seconds en then tried to run my commands, but that doesn't help either.
My working theory is that all scripts/plugins triggered by the startup sequence in Maya (userSetup.mel) only have access to a snapshot of the Maya internals - and that this snapshot doesn't get updated until after we have finished loading Maya and all startup scripts - which makes it too late to do what we need to do. I may very well be wrong about this, but every test I have done so far fails and I'm not sure about what to try next. I've even tried the ugly hack of having my script create another new scene (after the first one) - but this fails as well.
Any suggestions or ideas are greatly appreciated!
Cheers!
-atle
Comment