Hi,
i'm having some trouble trying to figure out how to move a bunch of selected features from a specific point layer in the map. This is what I have so far:
//****Get all of the selected ObjectIDs from the VLS layer.
var abLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.AsBuilts").First() as BasicFeatureLayer;
var selection = abLayer.GetSelection();
IReadOnlyList<long> selectedOIDs = selection.GetObjectIDs(); //save the selected OBJECTIDs to a list.
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); //create the Inspector
var moveFeature = new EditOperation();
moveFeature.Name = "Move AsBuilts";
//Loop through each selected OBJECTID
foreach (var oid in selectedOIDs)
{
insp.Load(abLayer, oid);
moveFeature.Move(..............); //**** This is where I get stuck....I don't know what to do
}
I think my approach is all wrong, but I'm not sure what to do. I'm not exactly sure how to interpret this: ArcGIS Pro 2.0 API Reference Guide
Thanks
Solved! Go to Solution.
To enable/disable your tool based on layers, you can use states and conditions. There is ConstructMarkerFromFont sample that demonstrates this.
Yes, I am actually looking through the WorkingWithDAML example right now, but will check out the ConstructMarkerFromFont sample too.
Thanks!
Hi Uma,
So I got it working, but was wondering if there is a better way. Is there a way to do what I want to do with just one event, or do I need to use all three to monitor the layers in the map?? This is in the Module1.cs of my MapTool code.
protected override bool Initialize()
{
LayersAddedEvent.Subscribe((args) =>
{
// Get the layers and also any selected OIDs for the AsBuilt and the SitePlan layers
var asBuiltLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_AsBuilts").FirstOrDefault() as BasicFeatureLayer;
var sitePlanLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_SitePlans").FirstOrDefault() as BasicFeatureLayer;
// Check that the required layers are in the map.
if (asBuiltLayer == null && sitePlanLayer == null)
FrameworkApplication.State.Deactivate(StateID);
else
FrameworkApplication.State.Activate(StateID);
}
);
DrawCompleteEvent.Subscribe((args) =>
{
// Get the layers and also any selected OIDs for the AsBuilt and the SitePlan layers
var asBuiltLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_AsBuilts").FirstOrDefault() as BasicFeatureLayer;
var sitePlanLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_SitePlans").FirstOrDefault() as BasicFeatureLayer;
// Check that the required layers are in the map.
if (asBuiltLayer == null && sitePlanLayer == null)
FrameworkApplication.State.Deactivate(StateID);
else
FrameworkApplication.State.Activate(StateID);
}
);
LayersRemovedEvent.Subscribe((args) =>
{
// Get the layers and also any selected OIDs for the AsBuilt and the SitePlan layers
var asBuiltLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_AsBuilts").FirstOrDefault() as BasicFeatureLayer;
var sitePlanLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_SitePlans").FirstOrDefault() as BasicFeatureLayer;
// Check that the required layers are in the map.
if (asBuiltLayer == null && sitePlanLayer == null)
FrameworkApplication.State.Deactivate(StateID);
else
FrameworkApplication.State.Activate(StateID);
}
);
return base.Initialize();
}
Hi Brian
To accomplish what you are doing, I would listen to the following events:
* You need to know when a map is initialized and the TOC is available. This event will help with that - MapViewInitializedEvent
* You will have to also listen to the ActiveMapViewChangedEvent to see when the active map view changes.
* Finally you can listen to MapMemberPropertiesChangedEvent to see if new layers being added\removed affects your tool.
* You might have to check the MapClosedEvent also.
The ProceduralSymbolLayers sample does something very similar - If you check the Module class file of this sample.
Thanks
Uma