MEL is not my forte, however I wrote this very simple script, basically select objects and then run it and it’ll automatically assign a VRayToon shader to all selected objects.
However, I do not know how ot create a + counter for the $vtoon and $vtoonset values so one could run the script multiple times. As it stand the script will work once due per scene due to it relying on incremental names. Can someone please help in adding this?
Just translated that to pymel and added some stuff. For now it just works for polymeshes and nurbs, dunno if others are needed. The numbering just starts with ‘01’ and increments when additional nodes and sets are created by the script.
import pymel.core as pm
def vrayPen():
'''Adds the current selection to a set and connects that to a VRayToonNode'''
selection = pm.ls(selection = True)
objects = []
for each in selection:
shape = each.getShape()
if shape.nodeType() == 'mesh' or shape.nodeType() == 'nurbsSurface':
objects.append(each)
if objects:
toonSet = pm.sets(name = 'set_vrayToonPen01')
toonNode = pm.createNode('VRayToon', name = 'toon_vrayToonPen01')
toonSet.usedBy[0] >> toonNode.excludeList
toonNode.excludeType.set(1)
print ('Assigned ' +toonNode +' to obbjects: ')
for each in objects:
print each
else:
print 'Please select some objects first!'
vrayPen()
You could just skip the if-statement and assign whatever you have selected:
import pymel.core as pm
def vrayPen():
'''Adds the current selection to a set and connects that to a VRayToonNode'''
selection = pm.ls(selection = True)
objects = []
for each in selection:
#shape = each.getShape()
#if shape.nodeType() == 'mesh' or shape.nodeType() == 'nurbsSurface':
objects.append(each)
if objects:
toonSet = pm.sets(name = 'set_vrayToonPen01')
toonNode = pm.createNode('VRayToon', name = 'toon_vrayToonPen01')
toonSet.usedBy[0] >> toonNode.excludeList
toonNode.excludeType.set(1)
print ('Assigned ' +toonNode +' to obbjects: ')
for each in objects:
print each
else:
print 'Please select some objects first!'
vrayPen()