Mandle bulb is an amazing+spectacular procedural geometry tool and a great mathematical algorithm, Solid angle has great tutorials on using mandle bulb, rendering it with arnold and also using it inside maya. But the mandle bulb inside maya is always static, hence here is a small python script in order to the mandle bulb animating inside of maya. Follow these steps :

Step 1:
Open a Maya scene , create a Arnold ->Standin . Follow these instructions in compiling a .dll file and creating the .ass file . Mkae sure everything is rendering inside Maya. Next step is to animate.

Step 2 :
Select the Standin for the outliner and run the below script from the script editor. This will create all the mandle attributes for the standin transform node. You can find them under the extra attributes section

node =
cmds.addAttr(node, ln='gridsize', k=True, at= 'short')
cmds.addAttr(node, ln='max_iter', k=True, at= 'short')
cmds.addAttr(node, ln='power', k=True, at= "float")
cmds.addAttr(node, ln='spheremult', k=True, at= "float")
cmds.addAttr(node, ln='orbitthresh', k=True, at= "float")
cmds.addAttr(node, ln='chunks', k=True, at= 'short')
cmds.addAttr(node, ln='threads', k=True, at= 'short')
cmds.addAttr(node, ln='julia', k=True, at= 'bool')

Step 2 :
Use all the attributes that you just created and start animating all the attributes like the way you want it , now is order for the .dll file to recognize all your changes for the mandle bulb you need to run the below script .

import pymel.core as pm
node =
endTime   = pm.playbackOptions(aet = True,q = True)  
startTime = pm.playbackOptions(ast = True,q = True) 
for i in range(int(startTime),int(endTime)):
    cmds.currentTime( i, edit=True )

    gridSize = cmds.getAttr(node[0]+'.gridsize',time=i)
    print gridSize
    max_iter = cmds.getAttr(node[0]+'.max_iter',time=i)
    power = cmds.getAttr(node[0]+'.power',time=i)
    spheremult = cmds.getAttr(node[0]+'.spheremult',time=i)
    orbitthresh = cmds.getAttr(node[0]+'.orbitthresh',time=i)
    chunks = cmds.getAttr(node[0]+'.chunks',time=i)
    threads = cmds.getAttr(node[0]+'.threads',time=i) 
    julia = "off" 

    frame = str(i)
    frameNumber = frame.rjust(4, '0')

    foo = open("Put your location to store .ass files/mandles."+str(frameNumber)+".ass", 'w')
    foo.write(' name cube\n')
    foo.write(' dso "Add the path to your .dll here"\n')
    foo.write(' load_at_init on\n')
    foo.write(' matrix\n')
    foo.write('  1 0 0 0\n')
    foo.write('  0 1 0 0\n')
    foo.write('  0 0 1 0\n')
    foo.write('  0 0 0 1\n')
    foo.write(' declare gridsize constant INT\n')
    foo.write(' gridsize '+str(gridSize)+'\n')
    foo.write(' declare max_iter constant INT\n')
    foo.write(' max_iter '+str(max_iter)+'\n')
    foo.write(' declare power constant FLOAT\n')
    foo.write(' power '+str(power)+'\n')
    foo.write(' declare spheremult constant FLOAT\n')
    foo.write(' spheremult '+str(spheremult)+'\n')
    foo.write(' declare orbitthresh constant FLOAT\n')
    foo.write(' orbitthresh '+str(orbitthresh)+'\n')
    foo.write(' declare chunks constant INT\n')
    foo.write(' chunks '+str(chunks)+'\n')
    foo.write(' declare threads constant INT\n')
    foo.write(' threads '+str(threads)+'\n')
    foo.write(' declare julia constant BOOL\n')
    foo.write(' julia '+str(julia)+'\n')
    foo.write(' declare Cval constant POINT\n')
    foo.write(' Cval -0 1 0\n')

The above code, creates all the necessary .ass files for all the attributes that you have animated. Remember in the above code you have to change address paths in 2 places: 1) Change the address path of your dso or .dll file 2) Change the path to the folder where the sequence of .ass files are stored.

What the above code is doing is, it goes into each frame , checks the parameters you have animated and creates a .ass file for each of your frames. Hence during batch render maya will load each of those .ass files and render the animated mandle bulb scene.

Step 4:
Hit the render button !!! Boom

One Comment

  • I’m getting the error “# Error: IOError: file line 21: 22”, which is with the file creation path. This path is exactly where it should be so I’m not sure why it is giving me this. Thoughts?

Leave a Reply