Controlling entity order from creation in grasshopper through dxf export

Is there a technique or work flow to guarantee the order of (line) entities when passing them from grasshopper (where the line entities are created and their order is specified), thence to “bake to Rhino,” and finally to “export to dxf R12”?

I need the order of the lines developed in grasshopper to be replicated exactly in the resulting DXF R12 export file.

Does a tree of lines (in grasshopper) need to be flattened prior to baking to guarantee a fixed, repeatable order in the dxf export file? Or is a more tedious branch-by-branch unpacking/repacking needed?

Does “bake” scramble the order? If this is possible, is there a bake component that does not scramble the order? And do other model parameters control or influence the order?

Does “dxf export” scramble the entity order within a layer? Does any attribute in the model affect the entity order within a given layer during the dxf export?

Generally I am getting the same results from Grasshopper and Rhino. Although there are so many variables. Is there a sample definition we could look at to see what is happening in your case?

Is there a relatively simple definition that reproduces the problem?

Are you going from GH >> Rhino >> “export to DXF R12”

Followed by:

Start a new model >> import from DXF >> then use GH to query the order of the lines?

I think the data tree branch order gets reversed somewhere in this process. If that is what happens everytime, I should be able to correct for that.

Oh, I see this is reading the same order that it was written. Be aware that Rhino can also reverse the list. I will do more research on this.

Which list is reversed in the example below. I am using Rhino 9 WIP to test this. I know in the past Rhino 7 and 8 might reverse file saves.

dxforder.dxf (6.4 KB)
readdxf.gh (6.5 KB)
dxforder.3dm (44.8 KB)