In the ArcGIS Pro SDK, I'm attempting to delete a subtype from a Subtype Group Layer, but in reading the API Reference Guide and trying out a few things, I'm not seeing a way to currently do this, as of ArcGIS Pro 2.9.
The closest I've gotten was to create the SubtypeGroupLayer object using SubtypeGroupLayerCreationParams and pointed to the layer file, where the subtype I want to delete isn't present, but this isn't ideal because I want to be able to use a data connection that isn't necessarily the same as the one in the layer file.
subtypeGroupLayerCreateParam = new SubtypeGroupLayerCreationParams(new Uri(layerInfo.LayerFilePath));
SubtypeGroupLayer layer = LayerFactory.Instance.CreateLayer<SubtypeGroupLayer>(subtypeGroupLayerCreateParam, layerContainerEdit, LayerPosition.AddToBottom);
I have tried to do so from the CIM object, by removing the subtype from the SubtypeLayers and setting the new definition to the layer, but while the definition shows the new list, it doesn't update the Subtype layers on the layer object.
var def = layer.GetDefinition() as CIMSubtypeGroupLayer; // layer has W, X, Y, and Z subtypes.
var newLayerUriArray = new string[] { "X", "Y", "Z" };
def.SubtypeLayers = newLayerUriArray;
layer.SetDefinition(def); // Layer still has W, X, Y, and Z subtypes
var updatedDef = layer.GetDefinition(def); // Definition Subtypes correctly has only X, Y, and Z subtypes
Is there currently a way to remove a subtype programmatically? A regular group layer has this capability, but I need to be able to do this on a subtype group layer.
Solved! Go to Solution.
Managed to figure this out after poking around again this morning. Rather than remove the subtype from the Subtype group layer itself, I just had to remove it through the map/layer container that I created the SubtypeGroupLayer in instead.
var subtypeGroupLayerCreateParam = new SubtypeGroupLayerCreationParams(new Uri(layerInfo.LayerFilePath));
SubtypeGroupLayer layer = LayerFactory.Instance.CreateLayer<SubtypeGroupLayer>(subtypeGroupLayerCreateParam, layerContainerEdit, LayerPosition.AddToBottom);
var layerToRemove = layer.Layers[1];
layerContainerEdit.RemoveLayer(layerToRemove);
Managed to figure this out after poking around again this morning. Rather than remove the subtype from the Subtype group layer itself, I just had to remove it through the map/layer container that I created the SubtypeGroupLayer in instead.
var subtypeGroupLayerCreateParam = new SubtypeGroupLayerCreationParams(new Uri(layerInfo.LayerFilePath));
SubtypeGroupLayer layer = LayerFactory.Instance.CreateLayer<SubtypeGroupLayer>(subtypeGroupLayerCreateParam, layerContainerEdit, LayerPosition.AddToBottom);
var layerToRemove = layer.Layers[1];
layerContainerEdit.RemoveLayer(layerToRemove);