Select to view content in your preferred language

Copy layer with subtypes breaks renderer

899
1
04-14-2012 12:17 PM
KellyChan
Emerging Contributor
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
Deactivated User

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

0 Kudos