DXF related question

 From:  pw
8703.10 In reply to 8703.9 
Hi Michael,
sorry to disturb you again.
You indicated a possible solution with scripts. I im not quite familiar with javascript and of course also not in detail with moi interfaces, nevertheless I tried to get a little bit deeper into that problem myself.

Meanwhile I did the following:

- I just bought a licence of moi (from our german reseller, I shifted my new radio to the next year, hopefully the update fee to V4 ist not to high :) ).
So I can get use of the next V4 betas. Hopefully you find the time to implement DXF-Layer to MoI-Style import.

- I programmed a script, which, sets Objects names:
---
script: /* DXF input rename objects V1*/
var Objects = moi.geometryDatabase.getObjects();

for ( var i = 0; i < Objects.length; ++i ) {
//{ Objects.item(i).name = 'obj_' + ((i+1)*10); }
{ Objects.item(i).name = (i+1)*10; }
}
moi.ui.alert( 'Rename objects V1\nDone: rename!\n' )
---
This works, although I tried to establish names like pl_10, cl_20 (polyline, circle ...) and so on for curve-objects. But I think, there is no interface for that?
By the way: MOI's visible objects are sorted in an alphabetical order, aren't they? Is there a way to show them in a order of the ObjectList (from GeometryDatabase.getObjects())?

- Then I programmed two scripts to go through the objectlist cw and ccw (attached) (shown by single selected objects).
This also works, probably there is a better way, then looping.

- Than I tried a manual sorting:
---
var Objects=moi.geometryDatabase.getObjects();
Objects.sortBySelectionOrder();
---
That doesn't work, I don't know, why. I can't see any effect?

-At last I tried a sorting back of the (disordered) objects. That also doesn't work:
---
script: /* reorder object V1*/
//moi.ui.alert( 'testest' );
var Objects=moi.geometryDatabase.getObjects();

Objects.sort(function(a, b){

return Number(a.item.name) - Number(b.item.name)
});
---
That script fails, and I don't know, if I could do that generally in such a short way (although it would be elegant). Maybe Objects (it should be a list) is not a sortable javascript array.
I am sure, you can give me a hint for this solution quickly.

Thank You in advance,
Paul