|
POST
|
Here is the full code I am trying to get to work. namespace Parcel_Select
{
internal class SelectParcel : MapTool
{
public SelectParcel()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Rectangle;
SketchOutputMode = SketchOutputMode.Map;
}
protected override Task OnToolActivateAsync(bool active)
{
return base.OnToolActivateAsync(active);
}
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
var parcellayer = (MapView.Active.Map.Layers.First(layer => layer.Name.Equals("Parcels")) as FeatureLayer);
//var parcellayer = (MapView.Active.Map.GetLayersAsFlattenedList().Where(layer => layer.Name.Equals("Parcels")) as FeatureLayer);
if (parcellayer == null) return Task.FromResult(true);
return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
var sqatialfilter = new SpatialQueryFilter()
{
FilterGeometry = geometry,
SpatialRelationship = SpatialRelationship.Intersects
};
MapView.Active.Map.SetSelection(null);
parcellayer.Select(sqatialfilter);
return base.OnSketchCompleteAsync(geometry);
});
}
}
}
... View more
02-02-2018
11:58 AM
|
0
|
2
|
5441
|
|
POST
|
I am trying to create a Map Tool where it only selects features in my "Parcels" layer. Some users will have the "Parcels" layer inside a Group Layer in the Map and some will not. .NET C# var parcellayer = (MapView.Active.Map.Layers.First(layer => layer.Name.Equals("Parcels")) as FeatureLayer); This works well if the layer is directly in the Map, but will crash if the layer is in a Group Layer in the Map. I have yet to figure out how to use a layer within a Group Layer in the same manner, simply because it is not what I am after. According to ProConcepts Map Authoring · Esri/arcgis-pro-sdk Wiki · GitHub , Working with Map Members, one should use FlattenedList because "Should you need to get a list without group layers hierarchy, use Map.GetLayersAsFlattenedList() method". When I do this, nothing happens when I try and use the new Map Tool .NET C# var parcellayer = (MapView.Active.Map.GetLayersAsFlattenedList().Where(layer => layer.Name.Equals("Parcels")) as FeatureLayer); I want to be able to make a Select Map Tool where it will select the "Parcels" layer regardless of if it is in a Group Layer or not. To add more confusion. I can run a stand alone Python Script within Pro and it will not matter if a feature layer is in a Group layer or not. Python selectPar = pm.SelectLayerByLocation("Parcels","WITHIN_A_DISTANCE",ZoneCaseFeat,"1000 Feet","NEW_SELECTION")
But if I run this same exact Python script from within .NET I have to put the Group in there first. Python selectPar = pm.SelectLayerByLocation(r"GroupLayerName\Parcels","WITHIN_A_DISTANCE",ZoneCaseFeat,"1000 Feet","NEW_SELECTION") But if I do this and run the Python script from within .Net it will work fine in or out of a group! Python aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Layers")[0]
ParcelsLayer = m.listLayers("Parcels")[0]
selectPar = pm.SelectLayerByLocation(ParcelsLayer,"WITHIN_A_DISTANCE",ZoneCaseFeat,"1000 Feet","NEW_SELECTION")
... View more
02-02-2018
11:41 AM
|
0
|
3
|
6602
|
|
POST
|
I suspect the License is not getting checked out. Try catching an exceptions on that before running the Tabulate. See the Code Sample here: CheckOutExtension—Help | ArcGIS for Desktop
... View more
12-14-2017
11:13 AM
|
1
|
0
|
1688
|
|
POST
|
Is there a way to use a relative path to that folder? Not everyone I share the project with will have the same file, folder, directories. Replace the "string tool_path" with a relative path. public async Task<IGPResult> ExecuteModel()
{
string tool_path = @"C:\Test_Folder\Base_Maps\Base_Maps.tbx\TestScript";
var parameters = Geoprocessing.MakeValueArray();
IGPResult gp_result = await Geoprocessing.ExecuteToolAsync(tool_path, parameters);
Geoprocessing.ShowMessageBox(gp_result.Messages, "GP Messages", gp_result.IsFailed ? GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);
return gp_result
} ;
... View more
11-27-2017
01:15 PM
|
0
|
1
|
5282
|
|
POST
|
Using a C# .Net add-in I need to run a custom python script tool from my toolbox from with-in the map in Pro. The sample "CallScriptFromNet" will not work because it runs the Python script from outside of the Pro environment. I have things in the script that uses many layers from the "CURRENT" map so it fails running it the way the sample shows. The script works great when I run it from the toolbox, but I cannot figure out how to run it from the .Net add-in. I am thinking I need to use some sort of combination of getting a Geoprocessing Project Item and Executing it?
... View more
10-25-2017
01:31 PM
|
2
|
12
|
8045
|
|
POST
|
Using a python script I need to figure out how split an line segment across the road and get its classification. Using my parcel data I need to calculate the segments values of adjacent polygons base on a classification. I used the intersect tool to get the initial segments. My problem is where the road is at. Anyone have any ideas how to handle this in a script? See attached image. The pink line needs to be split at the perpendicular intersection of the light and dark green polygons, and classified based on their values. Please note the shapes will not always be nice and squared. Also this script is for ArcGIS Pro.
... View more
07-18-2017
10:10 AM
|
0
|
0
|
1116
|
|
POST
|
Does anyone know a way to get Collector for ArcGIS to recognize the GPS location through the Verizon Jetpack GPS function other then using the turboirc.com GPSDirect sensor? Unfortunately GPSDirect is not currently supported on the Surface Pro 4, Windows 10 system.
... View more
07-13-2017
09:21 AM
|
0
|
0
|
932
|
|
IDEA
|
AddMessage's are very helpful when running custom scripts to show where and how it might fail. I would like to see these messages and error messages if it fails just like it does in the Geoprocessing tab when you run a script outside of a step. When run within a step in task there is no where to get the messages.
... View more
06-02-2017
06:53 AM
|
3
|
2
|
1952
|
|
POST
|
No, I mean the Tasks you write to walk someone through Steps of a process of creating something. Insert tab -> Project section -> Task
... View more
05-01-2017
09:34 AM
|
0
|
2
|
1555
|
|
POST
|
I have a Task where one of the Steps is to Automatically run a Python script. I have AddMessage's at points where the script might fail and showing the progress of the script. Where does it show these messages when it is a Step in a Task. When I run the script stand alone it shows these messages in the Geoprocessing tab, but not when it is a part of a Task. Is there a way to show the messages from the script as part of the Task?
... View more
04-28-2017
11:27 AM
|
0
|
4
|
1961
|
|
POST
|
I see now. I was getting an error thrown at me, but I had a service layer in the mxd it did not like. Thank you for the help.
... View more
04-18-2017
06:55 AM
|
1
|
0
|
3721
|
|
POST
|
I am not really interested seeing which server the layers are in, I am more interested in the name, more importantly it's name within a database. The problem I run into is when I list layers in the mxd it returns how it is named in the mxd not it's actual name in the database. If I could get the native feature class name, I could achieve what I am trying to do. When I list feature classes it returns the database and the version along with the feature class. ie targetdatabase.currentversion.myfeatureclass This I think I can handle by making it a string and split it.
... View more
04-18-2017
06:25 AM
|
0
|
4
|
3721
|
|
POST
|
import arcpy
arcpy.env.workspace = "Database Connections\SDE_Database.sde"
datasetList = arcpy.ListDatasets("*", "Feature")
datasetList.sort()
for dataset in datasetList:
print dataset
fcList = arcpy.ListFeatureClasses("*","",dataset)
sorts = sorted(fcList, key=lambda v: v.lower())
for fc in sorts:
print fc
jfkslist = arcpy.ListFeatureClasses("*")
sorts = sorted(jfkslist, key=lambda v: v.lower())
for sort in sorts:
print sort
mxd = arcpy.mapping.MapDocument(r"mxdpath/MXD.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE"):
print lyr.name
... View more
04-17-2017
02:42 PM
|
0
|
7
|
3721
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-23-2026 09:28 AM | |
| 2 | 05-21-2026 09:21 AM | |
| 1 | 05-19-2026 02:25 PM | |
| 1 | 05-19-2026 08:11 AM | |
| 1 | 04-17-2026 01:08 PM |
| Online Status |
Offline
|
| Date Last Visited |
05-28-2026
06:06 AM
|