Home Technical Talk

( Maya ) - Remove all colors sets on selected geo with Script ?

sculptn
polycounter lvl 7
Offline / Send Message
sculptn polycounter lvl 7
In maya is it possible to remove all colors sets on selected with a Script ? Thanks 

Replies

  • throttlekitty
    Offline / Send Message
    throttlekitty ngon master
    This one isn't great but it works despite the errors it throws. I also never knew color sets could be shared/instanced, kinda neat!

    {
    // get selected objects and check each for color sets, deleting them if found.
    string $sel[] = `ls -sl`;
    
    for ($obj in $sel){
    	string $colorSetList[] = `polyColorSet -q -acs`;
    	if (size($colorSetList) >1){
    		for ($colorSet in $colorSetList){
    			polyColorSet -delete;
    			}
    		}
    	if (size($colorSetList) <1){
    		print ($obj + " has no color sets." +"\n");
    	}
    	}
    }

  • sculptn
    Offline / Send Message
    sculptn polycounter lvl 7
    Your a legend thanks so much !! :)
  • sculptn
    Offline / Send Message
    sculptn polycounter lvl 7
    Will this work on one object. Seems to only work when I have one or more object selected that has a color set ?
  • throttlekitty
    Offline / Send Message
    throttlekitty ngon master
    It works on a single object for me. I did notice that the color set editor doesn't immediately detect that sets were deleted, I have to reselect the object for it to refresh.
  • sculptn
    Offline / Send Message
    sculptn polycounter lvl 7
    Got it thanks again :)
  • SMiles
    Offline / Send Message
    SMiles polycounter lvl 4
    import maya.cmds as mc
    import pprint
    sel = mc.ls(selection=True)
    for x in sel:
        mc.select(x, replace=True)
        color_list = mc.polyColorSet(query=True, allColorSets=True)
        print color_list
        if len(color_list) >= 0:
            for color_x in color_list:
                mc.polyColorSet(delete=True)
    mc.select(sel, replace=True)
    print "Color Sets deleted"



    The color sets seem to only work based per object, so selecting one object at a time and deleting all the color sets, and then rotating that selection to the next object in your original selection and repeating, seems to run with no errors :) 


Sign In or Register to comment.