|
POST
|
If you use ArcGIS Pro to load the file (from path) does that work?
... View more
06-29-2021
09:04 AM
|
0
|
0
|
1789
|
|
POST
|
Can you provide the code snippet that doesn't work?
... View more
06-29-2021
08:41 AM
|
0
|
0
|
1041
|
|
POST
|
Thanks for reporting this, an ArcGIS Pro Geodatabase team member was able to duplicate this problem when using a memory Geodatabase. The issue will be fixed in an upcoming Pro release.
... View more
06-28-2021
08:51 AM
|
1
|
0
|
3599
|
|
POST
|
I stand corrected. The Geodatabase team pointed out the error in my test add-in where I chose a scale larger than the precision. Once I fixed that error I get the proper result: I used the following code snippet to create the feature class. The 'selectedFeatureLayer' is a feature layer I get from the TOC in order to get my database connection. var selectedLayerTable = selectedFeatureLayer.GetTable();
var testName = $@"Point{DateTime.Now:HHmmss}";
var hasZ = false;
var hasM = false;
// Create a ShapeDescription object
var shapeDescription = new ShapeDescription(GeometryType.Point, SpatialReferences.WebMercator)
{
HasM = hasM,
HasZ = hasZ
};
var objectIDFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("ObjectID", FieldType.OID);
var stringFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("TheString", FieldType.String);
var intFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("TheInteger", FieldType.Integer);
var dblFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("TheDouble", FieldType.Double)
{
Precision = 9,
Scale = 5
};
var dateFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("TheDate", FieldType.Date);
using (var geoDb = selectedLayerTable.GetDatastore() as Geodatabase)
{
var fcName = $@"{testName}";
try
{
// Assemble a list of all of our field descriptions
var fieldDescriptions = new List<ArcGIS.Core.Data.DDL.FieldDescription>() {
objectIDFieldDescription,
stringFieldDescription,
intFieldDescription,
dblFieldDescription,
dateFieldDescription
};
// Create a FeatureClassDescription object to describe the feature class to create
var fcDescription =
new FeatureClassDescription(fcName, fieldDescriptions, shapeDescription);
// Create a SchemaBuilder object
SchemaBuilder schemaBuilder = new SchemaBuilder(geoDb);
// Add the creation of the Cities feature class to our list of DDL tasks
schemaBuilder.Create(fcDescription);
// Execute the DDL
bool success = schemaBuilder.Build();
}
catch (Exception ex)
{
MessageBox.Show($@"Exception: {ex}");
}
}
... View more
06-24-2021
03:01 PM
|
0
|
1
|
3639
|
|
POST
|
Thanks for reporting this. I was able to duplicate this problem. I will report the issue to the Geodatabase team.
... View more
06-24-2021
12:48 PM
|
0
|
0
|
3645
|
|
POST
|
Gary is correct, you have to change your shape's projection to match the projection of your layer: var mapPointProjected = GeometryEngine.Instance.Project(newMapPoint, testLayer.GetSpatialReference()); then use mapPointProjected as the shape value in your attr dictionary.
... View more
06-24-2021
06:48 AM
|
1
|
0
|
2043
|
|
POST
|
I am not sure what you mean, but the way to implement an interactive 'mouse click' on a map view is by implementing an 'ArcGIS Pro Map Tool' in your add-in by using the 'ArcGIS Pro Map Tool' item template: Once you have implemented this and copied the relevant mouse click code from the community sample i mentioned above, you can use the map tool's button on the ArcGIS Pro ribbon tab. If you want to use that same 'mouse click' tool from anywhere in your code or from a button on a dockpane you can use the Pro Guide for 're-using Pro Commands' to implement this functionality: ProGuide Reusing Pro Commands · Esri/arcgis-pro-sdk Wiki (github.com)
... View more
06-18-2021
09:02 AM
|
0
|
1
|
5791
|
|
POST
|
You can look at this example: arcgis-pro-sdk-community-samples/Map-Exploration/MapToolWithOverlayControl at master · Esri/arcgis-pro-sdk-community-samples (github.com) this shows the coordinates for a mouse click in an overlay control.
... View more
06-18-2021
08:19 AM
|
0
|
1
|
5828
|
|
POST
|
In case you use the 'default' label option and not an expression the following maptool should work: internal class SelectLabel : MapTool
{
public SelectLabel()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Rectangle;
SketchOutputMode = SketchOutputMode.Map;
}
protected override Task OnToolActivateAsync(bool active)
{
return base.OnToolActivateAsync(active);
}
protected override async Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
var labels = await QueuedTask.Run<string>(() =>
{
// use the geometry to make a new selection
var selectionSet = MapView.Active.SelectFeatures(geometry, SelectionCombinationMethod.New, true, true);
if (selectionSet.Count == 0) return "nothing selected";
// Layer of interest - use only the first layer in the collection
// for this example. You can search for specific layer using Linq
var selectedFeatureLayer = selectionSet.Keys.FirstOrDefault() as FeatureLayer;
// Get the selected Oids
var oids = selectionSet[selectedFeatureLayer];
// get the CIM definition from the layer
var cimFeatureDefinition = selectedFeatureLayer.GetDefinition() as ArcGIS.Core.CIM.CIMBasicFeatureLayer;
// get the view of the source table underlying the layer
var cimDisplayTable = cimFeatureDefinition.FeatureTable;
// this field is used as the 'label' to represent the row
var displayField = cimDisplayTable.DisplayField;
// collect all
var sb = new StringBuilder();
// search for all selected object ids
using (RowCursor rowCursor = selectedFeatureLayer.Search(new QueryFilter() { ObjectIDs = oids }))
{
// Iterate through the selected features
var labelFieldIndex = rowCursor.FindField(displayField);
while (rowCursor.MoveNext())
{
using (var row = rowCursor.Current) {
// Get the label field value
var labelForFeature = row[labelFieldIndex].ToString();
sb.AppendLine($@"oid: {row.GetObjectID()} label: {labelForFeature}");
}
}
}
return sb.ToString();
});
MessageBox.Show(labels);
return true;
}
} If the layer's label is defined by an expression (i.e. Arcade) there is no solution at this point. However, the Pro Dev team is working on providing script evaluation to the API in one of the upcoming releases.
... View more
06-17-2021
11:44 AM
|
1
|
0
|
1365
|
|
POST
|
It's not possible to retrieve the .sde file path from a layer, since only the connection properties are used by the layer not the original .sde file. You can verify this by deleting or renaming the .sde file and you will still be able to view your sde data on the map. But you can use this code to open the Geodatabase instead: // theLayer is the Mapmember from the TOC
var fc = theLayer.GetTable() as FeatureClass;
// use the layer's Datastore to access the Geodatabase
using (var gdb = fc.GetDatastore() as Geodatabase)
{
// use the open geodatabase "gdb" here (same a theLayer's datasource)
}
... View more
06-17-2021
11:07 AM
|
0
|
0
|
3915
|
|
POST
|
So specifically for a file geodatabase the GDB folder's name turns into the name in the catalog browser. You could use a Windows system function to rename the folder name. I will try a snippet and see it that works. Needless to say this won't work if the GDB has been opened in any way.
... View more
06-17-2021
09:02 AM
|
1
|
1
|
2992
|
|
POST
|
This Pro Guide (it's in the Wiki Kris mentioned above) shows how to make your own states & conditions: ProGuide Code Your Own States and Conditions · Esri/arcgis-pro-sdk Wiki (github.com)
... View more
06-17-2021
08:57 AM
|
1
|
0
|
5234
|
|
POST
|
It looks like the rename function is internal only, even so the API Reference guide shows the Name property's description as a getter/setter (which is not correct). My best guess is that this function is not trivial because depending on GDB type and the state of the GDB (open/closed) renaming might not be allowed. The other issue is that after the GDB project item has been renamed all dependencies have to be refreshed because renaming the GDB Project item will also rename the underlying database location (for example). That's probably the reason this functionality has been kept internal by the Pro developers.
... View more
06-17-2021
08:52 AM
|
1
|
1
|
2996
|
|
POST
|
In ArcGIS Pro the .sde path is not persisted anywhere after you create a layer by adding a feature class to a map. Instead all relevant connection properties are extracted from the .SDE file, if needed the user is prompted for the password, and the individual connection properties are then kept to reconnect the layer. You can utilize a layer’s connection information in code as shown in the sample snippet below. The snippet is taken from a button's OnClick method and uses the database connection from an existing SDE layer to retrieve all feature classes from the layer’s geodatabase. protected override async void OnClick()
{
var selectedLayer = MapView.Active.GetSelectedLayers().FirstOrDefault();
// set the sketch layer property (in order to obtain Zs, Ms as appropriate)
if (!(selectedLayer is BasicFeatureLayer theLayer))
{
MessageBox.Show("Select a feature layer on the TOC first");
return;
}
var lst = await QueuedTask.Run<List<string>>(() =>
{
var lstFcs = new List<string>();
var fc = theLayer.GetTable() as FeatureClass;
// use the layer's Datastore to access the Geodatabase
using (var gdb = fc.GetDatastore() as Geodatabase)
{
var fcDefs = gdb.GetDefinitions<FeatureClassDefinition>();
foreach (var tableDef in fcDefs)
{
lstFcs.Add(tableDef.GetName());
}
}
return lstFcs;
});
MessageBox.Show(string.Join(Environment.NewLine, lst.ToArray()));
}
... View more
06-16-2021
04:18 PM
|
0
|
2
|
3933
|
|
POST
|
Overlay graphics that are only adding graphics to the MapView. Overlay graphics is meant to help with Interactive MapView feedback. Like Chris said above you have to use a graphics layer instead. I used this community sample code in the past for copy/paste inheritance: arcgis-pro-sdk-community-samples/Map-Authoring/GraphicsLayers at master · Esri/arcgis-pro-sdk-community-samples (github.com) If you download the 'Practical Dockpane' / '2021 Palm Springs' Dev Summit slides and sample code (Tech Sessions · Esri/arcgis-pro-sdk Wiki (github.com)) you can also look the 'CompReporter' sample that is included. The code creates a graphics layer on the fly and uses it in a layout view (and export).
... View more
06-16-2021
01:27 PM
|
1
|
0
|
3102
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-29-2025 10:48 AM | |
| 1 | 05-24-2021 09:04 AM | |
| 1 | 12-03-2020 08:44 AM | |
| 1 | 10-07-2025 07:27 AM | |
| 2 | 12-29-2025 10:03 AM |
| Online Status |
Offline
|
| Date Last Visited |
05-21-2026
01:59 PM
|