"""Resets certain object attributes to 'by layer' (default).
Can pass optional arguments to not change all attributes listed below
Example, passing 'mt=False' will not change material back to by layer
Script by Mitch Heynick 27.01.19"""

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.DocObjects as do

def ResetSpecificObjAttributesToDefault(cs=True,ls=True,pc=True,pw=True,mt=True):
    msg="Select objects to reset properties to default"
    objIDs=rs.GetObjects(msg, preselect=True)
    if not objIDs: return
    
    rs.EnableRedraw(True)
    for objID in objIDs:
        obj=rs.coercerhinoobject(objID)
        attrs=obj.Attributes
        if cs: attrs.ColorSource=do.ObjectColorSource.ColorFromLayer
        if ls: attrs.LinetypeSource=do.ObjectLinetypeSource.LinetypeFromLayer
        if pc: attrs.PlotColorSource=do.ObjectPlotColorSource.PlotColorFromLayer
        if pw: attrs.PlotWeightSource=do.ObjectPlotWeightSource.PlotWeightFromLayer
        if mt: attrs.MaterialSource=do.ObjectMaterialSource.MaterialFromLayer
        sc.doc.Objects.ModifyAttributes(obj,attrs,True)
ResetSpecificObjAttributesToDefault()
