I am trying to write a 'duplicateLayer' function, and I've read all the related posts on these forums. It seems most of the responses have only addressed art inside a layer, and not nested layers/groups. I need to be able to duplicate ALL items in a layer.
I can get the sub-layers, but I can't figure out how to preserve order of the items in the new layer. For example, if my layer looks like this:
sub layer 1
sub art 1
I can call layer.pageItems to get my three art objects and duplicate them, and I can call layer.layers to get my one sub layer and duplicate it. But how do I preserve the same order of the art objects and sub layers with respect to each other?
After many dead ends and researching numerous forums, I've come to the conclussion that the Illustrator scripting for z-ordering is broken. The returned z-order on art, layers and groups is inconsistant. As far as I've been able to research, there is no workaround for this problem.
I don't use z-order just the indexes…
I'm trying to fix a similar issue. Did you ever find a solution?