POST
|
Ok, so why do things the easy way? This works, thank you! I think I know what the problem was. Because this has to be run on the MCT, I was setting the OnClick() event to async and using "await" on Geoprocessing.ExecuteToolAsync(). That wasn't necessary, and prevented the tool from operating on the selection. Thanks again!
... View more
05-17-2019
12:43 PM
|
0
|
0
|
1771
|
POST
|
Hi Brian, I tried that, but no luck. The GP tool takes a Feature Layer object as the first parameter. The GetSelection() method returns a Selection-typed object which causes the GP tool to throw an exception. Maybe there's a way to make a new Feature Layer in memory from the selection and run the tool on that. Problem there is that I would then need to somehow update the original feature class with the new values. However...I'm new to C# and the arcgis pro sdk, to it's very likely that I'm missing something simple.
... View more
05-17-2019
09:12 AM
|
0
|
0
|
1771
|
POST
|
Thanks Brian! This worked to get the selection, then write it to a list and cast to an array. I'm using the selected OIDs to set a Definition Query and then running the GP tool on the queried out layer. After it's done, I reset the original DefQuery if one existed: protected async override void OnClick()
{
//// TOOL PARAMETERS
var in_features = MapView.Active.Map.FindLayers("Roadways_Edits").First() as BasicFeatureLayer;
var currentDefQuery = in_features.DefinitionQuery;
// Get selected OIDs and set Def Query based on selection
await QueuedTask.Run(() =>
{
var getSelected = in_features.GetSelection();
var selectionList = in_features.GetSelection().GetObjectIDs().ToList();
string combinedString = string.Join(",", selectionList.ToArray());
in_features.SetDefinitionQuery(String.Format("OBJECTID IN ({0})", combinedString));
});
string geometry_property = "SEG_LEN LENGTH"; //this is ["SEG_LEN", "LENGTH"]
string length_unit = "MILES_US";
//// PATH TO TOOL USING TOOLBOX ALIAS
string tool_path = "management.CalculateGeometryAttributes";
//// CONSTRUCT THE VALUE ARRAY
var args = await QueuedTask.Run(() =>
{
// Create spatial reference and pass to value array constuctor
var spatial_ref = SpatialReferenceBuilder.CreateSpatialReference(3081);
return Geoprocessing.MakeValueArray(in_features, geometry_property, length_unit, null, spatial_ref);
});
//// RUN GP TOOL ASYNC
await Geoprocessing.ExecuteToolAsync(tool_path, args);
//// RESET DEF QUERY
await QueuedTask.Run(() =>
{
in_features.SetDefinitionQuery(currentDefQuery);
});
}
This method works, but seems a bit clunky. One issue I'm seeing is that the DefQuery persists in the FeatureLayer options menu. Is there another way to run this tool on the selected OIDs without a setting a Definition Query?
... View more
05-17-2019
08:18 AM
|
0
|
2
|
1771
|
POST
|
I'm trying to execute the CalculateGeometryAttributes geoprocessing tool with some hard-coded arguments. The code I have is working, but it's running on the entire feature class. I need it to only run on the selected records. Here is what I have now: //// Tool parameters
string in_features = @"C:PathToFeatureClass";
string geometry_property = "SEG_LEN LENGTH";
string length_unit = "MILES_US";
//// Path to tool using toolbox alias
string tool_path = "management.CalculateGeometryAttributes";
//// Construct the value array to be passed as parameter to ExecuteToolAsync
var args = await QueuedTask.Run(() =>
{
// Create spatial reference and pass to value array constuctor
var spatial_ref = SpatialReferenceBuilder.CreateSpatialReference(3081);
return Geoprocessing.MakeValueArray(in_features, geometry_property, length_unit, null, spatial_ref);
});
//// Execute the tool with hard-coded args
await Geoprocessing.ExecuteToolAsync(tool_path, args); I'm assuming I need to somehow check if any features are selected, then pass just those selected to the tool. Otherwise, it should run on all features. Any help is appreciated!
... View more
05-11-2019
01:45 PM
|
0
|
7
|
2312
|
POST
|
Glad it's working! I noticed that URL direction too. I also changed the base URL to this format: "https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=" Both work, but I believe this one is the more current standard: https://developers.google.com/maps/documentation/urls/guide#street-view-action
... View more
05-03-2019
12:33 PM
|
0
|
0
|
825
|
POST
|
Hi Dylan, Try creating a MapTool instead of a button. I had the exact same problem and found a solution here: https://community.esri.com/thread/190516-is-there-a-streetview-add-in-for-arcgis-pro One thing to keep in mind is that you need a way to deactivate the tool after you click on the map. Adding this line at the end of the QueuedTask works for me: FrameworkApplication.SetCurrentToolAsync("esri_mapping_exploreTool"); Based on this, I was also able to recreate a python addin that opens Google Maps at the MapView center and zoom level. Hope this helps!
... View more
05-03-2019
10:07 AM
|
1
|
0
|
2799
|
Title | Kudos | Posted |
---|---|---|
1 | 05-03-2019 10:07 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|