What determines the layer sort order in Rhino

Thanks Dale. We have thousands upon thousands of existing product files saved in DWG format. We are primarily an Autocad shop with the exception of the Industrial Designers that use Rhino exclusively.

Part of our job is maintenance and is a series of small fixes and quick updates.

I’ll try some time & motion and see whats involved in saving in 3DM and then back to DWG.

I think what he is saying is when he opens a DWG file in Rhino the layers aren’t sorted correctly. If I understand correctly it more has to do with Rhino import/conversion of DWG files to Rhino, then it does with the saveas dwg.

Just tried saving the existing DWG file to 3DM, closed and reopened, then saved to DWG.

No love. The file still saves in its Autocad order.

Most of our files have already been saved to DWG and Im assuming that Rhino is honoring that order even when its been saved to a 3DM file. Saving it again from 3DM back to DWG is not maintaining the layer order in DWG.

Was worth a try.

Hi @wm_c,

I guess I haven’t read back far enough to understand the problem.

Can you spell it our for me (again)?

Thanks,

– Dale

Here try this. Try opening this dwg in Rhino and see if the layers are sorted in order by name.

575 Degraw Street- 6.2.23_ Updated CADs.dwg (1.2 MB)

Sure, Disregard the beginning of the thread prior todays posts. I understand that the autocad sort order is more risk than reward to your devs, based on our previous conversations.

What I was hoping to do today was just find a way to “press” the LAYERS “sort” column header (programatically) from within the COMMAND LISTS box (yellow highlighted area)

Similar to the way in which I setup the grid for each DWG file we open up.

Is something like this possible? Was hoping to keep it simple using a function that already exists.

This is something I have seen in the past since we deal with a lot of archtiectural dwg files. When I convert them to a Rhino file the layers are all jumbled up. I think this is what is causing your issue.

Hi @djnelson75,

Thanks for the file. Yes I can that AutoCAD opens the file and displays them ascending order, not in the order they were created. I’m guessing that AutoCAD always opens files in this manner?

@wm_c - I don’t believe Rhino has a command to sort the layer list in ascending order outside of the Layers panel.

– Dale

OK, thanks DJ and Dale.

Just to be clear when you open the file they are in ascending order? When I open the file it looks like this.

Hi @djnelson75,

Just to be clear when you open the file they are in ascending order?

No. The are listed in the order in which they are read in from the dwg file.

If you open your file in AutoCAD and then open it in Rhino and click the Layer column to sort ascending, you’ll see the order of layers do not match.

There are lots of sorting algorithms.

AutoCAD sorting is based on the SORTORDER system variable.

Rhino 7’s Layers panel uses it’s own sorting algorithm: ON_wString::CompareAttributeName.

Rhino 8’s Layers panel is using logical sorting algorithm based on StrCmpLogicalW. Note, I have not see any pitch forks yet.

– Dale

This thread below may not have pitchforks but the barn door is open…

Layer Order DXF Export - Rhino / Rhino for Windows - McNeel Forum

Seems like a worthy endeavor to be able to save the layer order, IMHO.

Thanks Dale. I think we on the same page now as far as what we are seeing. It seems like as an option on import to sort the layers would be a nice feature. Maybe something added to the import options dialog. Now sorted by what is another question. Although having them sorted by something is better than nothing. IMO. Well I guess they are sorted by something, layer creation, I mean when you look at the list in layer dialog…

Screenshot 2023-10-12 065203

1 Like

Hopefully, one of those sort options would be based on the last saved version of the file.

I think that gets a little trickey when going from .3dm to .dwg back to .3dm (in your case). Autocad doesn’t allow you re-order the layer list like Rhino does. Meaning in Rhino you can move layers up and down in the list as you see fit. In Autocad you can’t do that.

All of our files are created in Rhino, either as 3DM or DWG. DWG is used for all client compatability purposes. 3DM are for internal development purposes only and are a tiny number of files compared to the DWG library.

McNeel has very talented developers. I’d bet they would create a solid set of Layer Management tools if they saw a market need. It is obviously not a priority at the moment.

Personally, layers are an INDEX. To have an index change every day, is frankly a waste of time.

Need more cowbell or a workaround for the time being.

Hi @djnelson75, @wm_c,

I’ve uploaded a new LayerSort plug-in to the Package Manager.

It provides a LayerSort command that lets you sort layers outside of clicking in the Layers panel.

Maybe this helps…

– Dale

2 Likes

I think the layer tools work really well in Rhino (defiantly better than autocad) provided you stay in the .3dm format. Again, I think the problem for you is that you are trying to work in the dwg format in Rhino, each time Rhino opens your dwg it goes through a conversion process and each time you do save dwg it converts it back. Maybe I wrong but the way I look at is if there is feature in Rhino that allows to do or store something but there isn’t a compatible feature in autocad when you save it out as a dwg that data is going to get lost, but if you stay in the 3dm format then you are fine. An example of this is nested layers. At any rate looks like Dale might have created something to allow the sort layer command which will be helpful.

Thank you Dale, I’ll test this in the command list window this afternoon. Looks very promising.

When will LayerSort be available in PackageManager? I just started PackageManager and searched for it, but it was not there.