Copying layers from one file to another in C#

I’m probably out of my depth here, but I came across code that lets you insert one block from within another file, which I think is awesome.

Props to the user archimax for this gem.

The issue I have is that it adds missing layers (an essential step) to the recipient file, but it does so according to the layer index of the source file or something and not by the name hierarchy.

I don’t know if it will make anything more clear, but here is an example of the results I get:

I have a file with 35 layers (most exist in the source file too). When I add all 145 layers from the source file, I get 149. They are just not where I expect them to be.

I expect:

I get:

1 Like