A script to have the used styles at the top
All  1-5  6-10

Previous
Next
 From:  MO (MO_TE)
11186.6 
Hi
I modified the above script:
It'll arrange your styles and keep your unused styles at the end of the list. (Keeps the names and colors intact)
code:
script: var gd = moi.geometryDatabase;
var styles = gd.getObjectStyles();
var counts = new Array(styles.length);
var unusedStylesList = {};
unusedStylesList.name=[];
unusedStylesList.color=[];
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];
	}
}
moi.geometryDatabase.styleEditorOpened();
for (var i = 0; i < styles.length; ++i)
{
	if (counts[i] == 0)
	{
		unusedStylesList.name.push(styles.item(i).name);
		unusedStylesList.color.push(styles.item(i).color);
		styles.item(i).remove();
	}
}
for(i=0;i<unusedStylesList.name.length;i++)
{
	var style = moi.geometryDatabase.addStyle();
	style.name = unusedStylesList.name[i];
	style.color = unusedStylesList.color[i];
}
moi.geometryDatabase.styleEditorClosed();
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  codi (CODISESAN)
11186.7 In reply to 11186.6 
wow !!! great.
thanks guys.

Mario
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  christian (CHRI)
11186.8 In reply to 11186.6 
well done MO
We are lucky to have great people like you on this forum.

Thanks
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  MO (MO_TE)
11186.9 In reply to 11186.8 
Thank you Christian :)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  wayne hill (WAYNEHILL5202)
11186.10 
Great work Mo!
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages: All  1-5  6-10