purge unused layers

 From:  Michael Gibson
3774.2 In reply to 3774.1 
Hi okapi, here's a script that should do it. Add in a new shortcut key and paste in the following for the Command part:

script:var gd = moi.geometryDatabase; var styles = gd.getObjectStyles(); var counts = new Array(styles.length); for ( var i = 0; i < counts.length; ++i ) { counts[i] = 0; } var objs = gd.getObjects(); for ( var i = 0; i < objs.length; ++i ) { var obj = objs.item(i); if ( obj.styleIndex < counts.length ) ++counts[obj.styleIndex]; var subobjs = obj.getSubObjects(); for ( var j = 0; j < subobjs.length; ++j ) { var subobj = subobjs.item(j); if ( subobj.styleIndex < counts.length ) ++counts[subobj.styleIndex]; } } for ( var i = 0; i < styles.length; ++i ) { if ( counts[i] == 0 ) styles.item(i).remove(); }

- Michael