privat void DeleteFeatures(IFeatureLayer featLayer) { DeleteFeatures deleteFeatures = new DeleteFeatures(); deleteFeatures.in_features = featLayer; RunTool(GP, deleteFeatures, null); }
Now i need help making the code. You wrote "Map.get_Layers((UID)uid, true);" . Is "Map" an interface (private IMap Map)? Here too: "Map.SelectByShape(geom, null, false);"You also wrote "editor = ArcMap.Application.FindExtensionByCLSID(uidEditor) as IEditor;" and "private IMxDocument MxDoc = ArcMap.Document;" . Is "ArcMap" an "internal static class" like in internal static class ArcMap{ private static IApplication s_app = null; private static IDocumentEvents_Event s_docEvent;}?
private IMap map = ArcMap.Document.FocusMap;
The thing is that points should be selected automatically (for example, all points in active view). And then deleted. It seems i forgot to mention it the beginning of this thread 🙂
private IMxDocument MxDoc = ArcMap.Document; protected override void OnClick() { IActiveView activeView = MxDoc.ActiveView; IEnvelope env = activeView.Extent; IGeometry geom = (IGeometry)env; Map.SelectByShape(geom, null, false); activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, env); }
IUID uid = new UIDClass(); uid.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}"; IEnumLayer enumLayerByName = Map.get_Layers((UID)uid, true); enumLayerByName.Reset(); ILayer iLayer = enumLayerByName.Next(); while (!(iLayer == null)) { if (iLayer.Name != "your_layer_name") { IFeatureLayer featLayer= (IFeatureLayer)iLayer; featLayer.Selectable = false; } iLayer = enumLayerByName.Next(); }
Yes, I believe I need "users to sketch an envelope on the map that indicates which features they want to delete." So yes, i need a tool.
Thank you for a great response. But i'm still wondering about using Ienvelope. Maybe you or somebody else could give me just an example how to use envelope. Just to learn more about Visual Studio.
private IEditor editor; private IWorkspace workspace; private IFeatureLayer featLayer; private void DeleteFeatures(IFeatureLayer featLayer) { //if there is already a selection on feature layer you can get all selected features IFeatureSelection featureSelection = featLayer as IFeatureSelection; ISelectionSet selectionSet = featureSelection.SelectionSet; ICursor cursor; //in search method you can use QueryFilter to query features or you can use 'null' and you will get all features in layer selectionSet.Search(null, false, out cursor); IRow row = cursor.NextRow(); editor.StartEditing(workspace); while (row != null) { row.Delete(); row = cursor.NextRow(); } editor.StopEditing(true); }
private void GetEditor() { UID uidEditor = new UIDClass(); uidEditor.Value = "esriEditor.Editor"; editor = ArcMap.Application.FindExtensionByCLSID(uidEditor) as IEditor; }
private void GetFileWorkspace(IFeatureLayer featLayer) { IFeatureDataset featDataset = featLayer.FeatureClass.FeatureDataset; IFeatureWorkspace featWorkspace = (IFeatureWorkspace)featDataset.Workspace; workspace = (IWorkspace)featWorkspace; }
private void GetMapLayers() { uid.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}"; IEnumLayer enumLayerByName = map.get_Layers((UID)uid, true); enumLayerByName.Reset(); ILayer iLayer = enumLayerByName.Next(); while (!(iLayer == null)) { switch (iLayer.Name) { case "YourLayerName": featLayer = (IFeatureLayer)iLayer; break; .........(more cases) default: break; } } }
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.