|
POST
|
I tried the following on both 2.9 and 3.0 and it seems to work (no FieldDescription == null is returned): protected override async void OnClick()
{
var mapMembers = MapView.Active.Map.GetLayersAsFlattenedList().OfType<MapMember>();
var result = await QueuedTask.Run<string>(() =>
{
StringBuilder sb = new StringBuilder();
foreach (var mapMember in mapMembers)
{
sb.AppendLine($@"member: {mapMember.Name} is Standalone: {mapMember is StandaloneTable} is BasicFeatureLayer {mapMember is BasicFeatureLayer}");
if (!(mapMember is StandaloneTable || mapMember is BasicFeatureLayer)) continue;
var dispTable = mapMember as IDisplayTable;
var fieldDescriptions = dispTable.GetFieldDescriptions();
foreach (var field in fieldDescriptions)
{
field.IsVisible = true;
}
sb.AppendLine($@" => table: {dispTable.GetTable().GetName()} fields: {fieldDescriptions.Count}");
dispTable.SetFieldDescriptions(fieldDescriptions);
}
return sb.ToString();
});
mapMembers = MapView.Active.Map.GetStandaloneTablesAsFlattenedList().OfType<MapMember>();
result += await QueuedTask.Run<string>(() =>
{
StringBuilder sb = new StringBuilder();
foreach (var mapMember in mapMembers)
{
sb.AppendLine($@"member: {mapMember.Name} is Standalone: {mapMember is StandaloneTable} is BasicFeatureLayer {mapMember is BasicFeatureLayer}");
if (!(mapMember is StandaloneTable || mapMember is BasicFeatureLayer)) continue;
var dispTable = mapMember as IDisplayTable;
var fieldDescriptions = dispTable.GetFieldDescriptions();
foreach (var field in fieldDescriptions)
{
field.IsVisible = true;
}
sb.AppendLine($@" => table: {dispTable.GetTable().GetName()} fields: {fieldDescriptions.Count}");
dispTable.SetFieldDescriptions(fieldDescriptions);
}
return sb.ToString();
});
MessageBox.Show(result);
}
... View more
08-05-2022
10:19 AM
|
0
|
0
|
2166
|
|
POST
|
I was able to duplicate this issue. It is a bug. I also noticed that when you change this line in the constructor from this: SketchOutputMode = SketchOutputMode.Screen; to this: SketchOutputMode = SketchOutputMode.Map; This will limit your tool to Maps only it will not work on Scenes (3 D), however, the active tool doesn't switch to the Explore tool anymore.
... View more
08-03-2022
07:14 AM
|
0
|
1
|
891
|
|
POST
|
Like Charles said we don't have enough code to see the problem, but i would also check your CrossHairControl and make sure that mapViewOverlayControl is defined.
... View more
08-02-2022
11:09 AM
|
1
|
0
|
1752
|
|
POST
|
You are correct and it looks like you can add Topology items via the Pro UI | Add Data from Path: and here is the result (using the sample dataset from the community samples): However, when i try to perform the same operation through the API, the LayerFactory fails as you described: await QueuedTask.Run(() =>
{
var path = @"C:\Data\Topology\GrandTeton.gdb\BackCountry\Backcountry_Topology";
Uri uri = new Uri(path);
// fails:
LayerFactory.Instance.CreateLayer(uri, MapView.Active.Map);
}); I tried different methods and also tested this under 2.9 to no avail. The only workaround i was able to find was adding the whole feature dataset instead of the Topology. This works: await QueuedTask.Run(() =>
{
var path = @"C:\Data\Topology\GrandTeton.gdb\BackCountry";
var uri = new Uri(path);
LayerFactory.Instance.CreateLayer(uri, MapView.Active.Map);
}); but needless to say, it will add all layers of that feature dataset to the map. Consequently, all unwanted (or duplicated) layers have to be removed from the map's table of content. Thanks for finding this, i will report it as a bug.
... View more
08-01-2022
02:38 PM
|
0
|
1
|
2618
|
|
POST
|
Maybe i don't understand your workflow, but Topologies are applied to a feature dataset and not to a map. In geodatabases, a topology is an arrangement that defines how point, line, and polygon features share coincident geometry. Topologies provide a mechanism to perform integrity checks on data and help validate and maintain better feature representations in a geodatabase. To do this you have to use the GP Tool: Import Topology. The tool requires two parameters: the feature dataset for which you want to create a topology and a topology definition file (XML - exported from a toplogy). The tool creates a topology in the specified feature dataset, however, this only works if the feature dataset contains the feature classes listed in the topology_definition_file. Once you have a topology in your geodatabase you can use the topology functionality outlined in this ProConcept document: ProConcepts Topology · Esri/arcgis-pro-sdk Wiki (github.com) You can find code examples in these ProSnippets: ProSnippets Topology · Esri/arcgis-pro-sdk Wiki (github.com)
... View more
08-01-2022
10:23 AM
|
0
|
1
|
2623
|
|
POST
|
You are getting copy of the array of pixels from the pixel block corresponding to the plane (== 0) with a copy of the pixel data (second argument is set to true). Array array = block.GetPixelData(0, true); But you are not using the array in your analysis, maybe try: Array array = block.GetPixelData(0, true);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int pixelValue = array[x, y];
}
} I don't have a raster handy, so i am not sure which array dimension corresponds to x (width) and y (height). I assume that the dimension arguments correspond to sourcePixels.GetValue (x, y), but you should double check this in your code to make sure that's the case.
... View more
08-01-2022
06:07 AM
|
2
|
0
|
2473
|
|
POST
|
Charlie's suggestion is the way to go, however, you have to compute the x/y ratios to position the user control in the middle of the screen. For that you have the use the active mapview's GetViewSize(). if (MapView.Active == null) return;
var mapView = MapView.Active;
var crossHairControl = new CrossHairControl();
// use the active mapview to get the size of the mapview display
var xRatio = 0.0;
var yRatio = 0.0;
var viewSize = mapView.GetViewSize();
if (viewSize.Width != 0.0 && viewSize.Height != 0.0)
{
var xPosition = viewSize.Width / 2;
var yPosition = viewSize.Height / 2;
// now offset for 1/2 of the user control's size
xPosition -= 16;
yPosition -= 16;
xRatio = xPosition / viewSize.Width;
yRatio = yPosition / viewSize.Height;
}
// Create a MapViewOverlayControl using the user control
var mapViewOverlayControl = new MapViewOverlayControl(
crossHairControl, true, false,
false, OverlayControlRelativePosition.Center, xRatio, yRatio);
//Add to the active map view
mapView.AddOverlayControl(mapViewOverlayControl); I attached my sample add-in, but the result should look like this:
... View more
07-30-2022
09:06 AM
|
1
|
0
|
1771
|
|
POST
|
When you create the MapPoint you have to include the Camera's spatial reference. This worked for me, but it's Pro 3.0: MapPoint cameraPoint = MapPointBuilderEx.CreateMapPoint(cameraBefore.X,
cameraBefore.Y, cameraBefore.SpatialReference);
var projectedPoint = GeometryEngine.Instance.Project(cameraPoint, SpatialReferences.WGS84) as MapPoint;
MessageBox.Show($@"projected [x,y]: {projectedPoint.X}, {projectedPoint.Y}");
... View more
07-27-2022
04:13 PM
|
1
|
0
|
708
|
|
POST
|
I guess i didn't understand your workflow correctly. But in general, configurations allow you to modify the DAML when ArcGIS Pro starts up, but before the UI is activated. This allows total control over the DAML content and hence the UI. Add-ins are still loaded even if you run ArcGIS Pro with a Configuration, but you could modify the DAML of those Add-ins too (since the Add-in DAML will be included when Pro starts). Now states & conditions can be used to control the visibility of Tabs, Groups in an Add-in (no need for a Configuration to do this). This ProGuide is talking about tabs and groups: ProGuide Ribbon Tabs and Groups · ArcGIS/arcgis-pro-sdk Wiki (github.com) If you use a condition on an ArcGIS Pro button you can only disable the button, but you cannot hide it (or delete it) by using a condition. But if you add your edit button (like the 'Delete' button) to an Edit group you can hide the whole group. To test this out i modified the 'working with daml' sample code and hooked a new group 'myEdit_group' to the existing state/condition of the sample. I can now use the 'Toggle State' button (which changes the condition) to hide or show the 'myEdit_group': after the toggle: This is the DAML that does the work: <group id="myEdit_group" caption="My Edit Tools" keytip="X1"
condition="example_state_condition">
<button refID="esri_core_saveProjectButton" />
<button refID="esri_core_saveProjectAsButton" />
</group> and this adds the group to the mapping tab: <updateModule refID="esri_mapping">
<tabs>
<updateTab refID="esri_mapping_homeTab">
<insertGroup refID="myEdit_group"/>
</updateTab>
</tabs>
...
... View more
07-27-2022
03:57 PM
|
0
|
0
|
2214
|
|
POST
|
Check the return value of edOp.Execute(); It might be false. Also check if edOp.IsEmpty is set. But yes I agree with Rich i don't see the need for a chained operation here either.
... View more
07-27-2022
11:44 AM
|
0
|
0
|
1435
|
|
POST
|
I couldn't find an easy way to do this. We did reach out to the Dev team to see if we overlooked something here, but in the meantime the following snippet resets the extent to the extent before adding the new feature layer: QueuedTask.Run(() =>
{
var map = MapView.Active.Map;
var flyrCreateParam = new FeatureLayerCreationParams(new Uri(@"C:\Data\Admin\AdminData.gdb\USA\cities"))
{
Name = "World Cities",
IsVisible = true
};
var cameraBefore = MapView.Active.Camera;
var featureLayer = LayerFactory.Instance.CreateLayer<FeatureLayer>(
flyrCreateParam, map);
if (cameraBefore != null)
MapView.Active.ZoomTo(cameraBefore);
}); Needless to say, this is just a work-around, once we hear back from the Dev team, I will let you know if there's a better way to accomplish your workflow.
... View more
07-27-2022
11:35 AM
|
0
|
0
|
870
|
|
POST
|
I think you misunderstood, only the button images (*.png files usually located in the images/darkimages folders) need to be set to build action "AddinContent", not the class files (*.cs) those need to be compiled.
... View more
07-26-2022
01:49 PM
|
0
|
0
|
815
|
|
POST
|
If you create a 'Manage Configuration' instead of an 'Add-in Module' you can customize the User Interface. See details here: ProGuide Configurations · Esri/arcgis-pro-sdk Wiki (github.com) The ProGuide also references a sample that changes the user interface by removing most ribbons / buttons: arcgis-pro-sdk-community-samples/Framework/ConfigWithMap at master · Esri/arcgis-pro-sdk-community-samples (github.com) and the sample's 'custom' UI looks like this: An earlier version of the sample checked user permission to determine if the UI was read-only or read/write by controlling the DAML of the 'Start Editing' button, but for simplicity of the sample this feature was removed.
... View more
07-25-2022
10:16 PM
|
0
|
1
|
2231
|
|
POST
|
If you need a custom map tool that allows you to select a single annotation feature and then allows you to move it you can use the following code: internal class MoveAnnoTool : MapTool
{
public MoveAnnoTool()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Point;
SketchOutputMode = SketchOutputMode.Map;
}
protected override Task OnToolActivateAsync(bool active)
{
return base.OnToolActivateAsync(active);
}
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
{
// execute on the MCT
return QueuedTask.Run(() =>
{
// find features under the sketch
var features = MapView.Active.SelectFeatures(geometry);
// only one feature ...
if (features.Count != 1) return false;
// this works only if one annotation feature has been
// selected
var annoSelected = 0;
foreach (var annoLayer in features.ToDictionary().Keys.OfType<AnnotationLayer>())
{
// are there features?
var featOids = features[annoLayer];
annoSelected += featOids.Count;
}
if (annoSelected == 1)
RunOnUiThread(() =>
{
// or use ICommand.Execute
ICommand cmd = FrameworkApplication.GetPlugInWrapper("esri_editing_EditVerticesMove") as ICommand;
if ((cmd != null) && cmd.CanExecute(null))
cmd.Execute(null);
});
return true;
});
}
}
/// <summary>
/// utility function to enable an action to run on the UI thread (if not already)
/// </summary>
/// <param name="action">the action to execute</param>
/// <returns></returns>
internal static void RunOnUiThread(Action action)
{
try
{
if (IsOnUiThread)
action();
else
System.Windows.Application.Current.Dispatcher.BeginInvoke(action);
}
catch (Exception ex)
{
MessageBox.Show($@"Error in OpenAndActivateMap: {ex.Message}");
}
}
/// <summary>
/// Determines whether the calling thread is the thread associated with this
/// System.Windows.Threading.Dispatcher, the UI thread.
///
/// If called from a View model test it always returns true.
/// </summary>
public static bool IsOnUiThread => FrameworkApplication.TestMode || System.Windows.Application.Current.Dispatcher.CheckAccess();
} Click the tool and then click on an annotation feature, to select a feature, next the Pro Move command will be activated, and you can now move (rotate, scale) the annotation. Once you moved a feature you can repeat. You can insert additional custom code as needed.
... View more
07-22-2022
02:53 PM
|
1
|
1
|
1004
|
|
POST
|
Thanks Bill, I found similar issues before where introducing additional logging changed the timing and hence the execution sequence of threads that caused similar issues. I will look over your code snippet and let you know if i see anything suspicious.
... View more
07-21-2022
09:31 AM
|
1
|
0
|
4751
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-07-2025 07:27 AM | |
| 2 | 4 weeks ago | |
| 1 | 07-30-2025 12:03 PM | |
| 1 | 10-06-2025 01:19 PM | |
| 1 | 10-06-2025 10:37 AM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|