Can't initialize turtle in Maya through scripting

Can't initialize turtle in Maya through scripting

Anonymous
Not applicable
1,549 Views
2 Replies
Message 1 of 3

Can't initialize turtle in Maya through scripting

Anonymous
Not applicable

I have a maya python tool that is supposed to load turtle, set it as the renderer, and then bake vertex AO on the selected object. The whole thing works except that when the user first opens Maya, it won't actually initialize the first time. It doesn't create the "TurtleDefaultBakeLayer" node for the script to modify attributes on. The user has to manually open the render settings window and then click on the "TURTLE" tab next to the "Common" tab for it to bake anything. After that it works exactly how it should with or without that Render Settings window open.

 

My question is, how do I get a freshly opened Maya to get Turtle to initialize and instantiate those components without the user needing to open the Render Settings window?

 

def initializeTurtle(self):
    #Load Turtle
    cmds.loadPlugin('Turtle')        

    #Set renderer
    cmds.setAttr("defaultRenderGlobals.currentRenderer", "turtle", type="string")

TurtleUI.JPG

0 Likes
Accepted solutions (1)
1,550 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

For anyone that was curious about solving this problem without opening the render settings window, the only viable solution we could come up with was to manually create the nodes Turtle needed, instead of relying on its automatic instantiation.

 

def initializeTurtle(self):
        #Load Turtle
        
        pluginStatus = cmds.pluginInfo( "Turtle", q = True, l = True, n = True )
        if pluginStatus == False:
            cmds.loadPlugin( "Turtle")
            
        #Create bake nodes
        cmds.setAttr("defaultRenderGlobals.currentRenderer", "turtle", type="string")
        tOptions = cmds.createNode ("ilrOptionsNode", name="TurtleRenderOptions")
        tBakeLayer = cmds.createNode ("ilrBakeLayer", name="TurtleDefaultBakeLayer")
        tbakeLayerMgr = cmds.createNode ("ilrBakeLayerManager", name="TurtleBakeLayerManager")

        cmds.connectAttr(tOptions+".message", tBakeLayer+".renderOptions")
        cmds.connectAttr(tBakeLayer+".index", tbakeLayerMgr+".bakeLayerId[0]")

0 Likes
Message 3 of 3

Anonymous
Not applicable

For MEL, I have found a simple solution using the line:

 

renderWindowRender bake renderView;

Before your bake command.

0 Likes