PurgeLayer : Purger les calques by Michael Gibson
Supprime les calques (les styles) qui sont vides!
P
|
script:/*Puger les styles*/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(); }
|