##Maya Wireframe Rendering Script ##Automatically sets up Maya to render nice wireframes. Requires at least Maya 2011, though tested only with 2012. ## Automatic setup of nice wireframe renders ## by using Maya's vector renderer ## import pymel.all as pm ## Get a list of all selected objects objs = pm.ls(selection=True) ## Assign a new surface shader to everything mat = pm.shadingNode('lambert', asShader=True, name ="vectorSurfaceMat") mat.color.set( [0,0,0] ) sg = pm.sets( renderable=True, noSurfaceShader=True, empty=True, name='vectorSurfaceSg' ) mat.outColor >> sg.surfaceShader pm.sets(sg, edit=True, forceElement=objs) ## Loop through all objects ## attempt to make them hard edged ## attempt to turn on hard edge propagation ## for rendering smoothed SDS models ## (note, this is useless for the Vector Renderer) ## since it ignore "SmoothMesh" properties for obj in objs: try: pm.polySoftEdge( obj, angle=0, ch=1 ) obj.getShape().propagateEdgeHardness( 1 ) except: print('Failed on an element of the selection') ## Attempt to lead the vector rendering plugin try: pm.loadPlugin( "VectorRender.mll" ) except: print( "Vector renderer is either already loaded, unavailable, or giving an error. Most likely it is simply already loaded. Proceeding." ) ## Set the vector renderer as active d = 'defaultRenderGlobals' opts = pm.PyNode( d ) opts.ren.set('mayaVector') ## Made vector renderer options ## we have to do this here because Maya doesn't ## make them until the UI comes back after the script v = 'vectorRenderGlobals' try: vOpts = pm.PyNode( v ) except: vOpts = pm.createNode( v, n=v ) ## Setup our vector rendering options to make nice wireframes vOpts.includeEdges.set(1) vOpts.edgeWeight.set(3) vOpts.edgeColor.set( [1,1,1] ) vOpts.curveTolerance.set(0) ## All done! print( "Setup of wireframe rendering via vector renderer is complete!" ) ## Last line for bottom ## of all Maya Python scripts to avoid ## Maya's blank space parsing bug. pass