Copy layer with subtypes breaks renderer

753
1
04-14-2012 12:17 PM
KellyChan
New Contributor II
I try to copy a layer with subtypes between two dataframes. The symbology is defined on the subtype field. After copy, the value field in the renderer is reset to the first field in the layer. If I change the name of the new layer to something different, it seems to behave better.

I'm trying to make side-by-side comparison. Copying the whole map doesn't help. Even layerfile doesn't help.

What did I do wrong in the copy code? How should I copy a layer (with subtypes) in ArcMap? Thanks.

IObjectCopy copier = new ObjectCopyClass();
var newLayer = copier.Copy(oldLayer) as ILayer;
myMap.AddLayer(newLayer);

// ArcMap?? Bad subtypes renderer after copy. Workaround.
newLayer.Name = "name differs from old layer name";
0 Kudos
1 Reply
DanielBachmann1
New Contributor

Its a bit late, but it works with ArcObjects.Net 10.4.1 and helped me a lot, so thanks 😉

0 Kudos