|
POST
|
Just add a boolean variable in your Module class, let's call it IgnoreSelection internal class Module1 : Module
{
private static Module1 _this = null;
internal static bool IgnoreSelection = false;
...
} and set the IgnoreSelection to true during your programmatic selection: Module1.IgnoreSelection = true;
table.Select(new QueryFilter { ObjectIDs = new List<long> { newObjectId } },
SelectionCombinationMethod.Add);
Module1.IgnoreSelection = false; and ignore the selection in your selection event handler: private void OnMapSelectionChanged(MapSelectionChangedEventArgs obj)
{
if (Module1.IgnoreSelection) return;
// ...
}
... View more
05-15-2023
08:54 AM
|
2
|
1
|
996
|
|
POST
|
The error that you are getting indicates that one of the items in a collection that you pass into the ExecuteTool function has expired. This can happen if you assign a reference to a collection that is set to null while the GP Tool is running. There are two collections in your snippet above the environment settings and the arguments. Since the argument items are all hard coded (and hence can't become null) i would suggest changing the environment settings: var srEnv = Geoprocessing.MakeEnvironmentArray(outputCoordinateSystem: map.SpatialReference.Wkt); This should keep the spatial reference setting alive even is map gets set to null. However, since we don't see the complete code snippet that fails it's impossible to guess the cause of the error.
... View more
05-12-2023
05:12 PM
|
0
|
1
|
763
|
|
POST
|
I haven't tested this in a while, but i remember implementing the migration tool so that you run it when you right click on the solution and run it. That should convert all projects in the subtree under the solution folder. Make sure that all projects under the solution folder are projects that you need to upgrade.
... View more
05-11-2023
10:26 AM
|
0
|
0
|
1341
|
|
POST
|
You are correct the Margins get set by the esri button style. But you can override the Margins: <Button BorderThickness="0" Background="Transparent"
Command="{Binding CommandShowDataGroups}" Style="{DynamicResource Esri_Button}"
Margin="0">
<StackPanel Orientation="Horizontal" Width="120" Height="22">
...
</StackPanel>
</Button> Now you get the same 'theme' behavior as if you use the Button in a Dockpane: Ribbon - mouseover: Dockpane mouseover:
... View more
05-11-2023
10:22 AM
|
0
|
0
|
1245
|
|
POST
|
Assuming that you are using the CancelableProgressorSource: You can try setting the following properties for the CancelableProgressorSource instance to change the Progress bar UI: // Gets or sets the message of the progress dialog displayed while the associated
// Task is executing.
public string Message { get; set; }
// Gets or sets the status of the progress dialog displayed while the associated
// Task is executing.
public string Status { get; set; }
// Gets or sets the extended status of the progress dialog displayed while the associated
// Task is executing.
public string ExtendedStatus { get; set; }
// Gets or sets the progress bar position within the progress dialog displayed while
// the associated Task is executing.
public uint Value { get; set; }
// Gets or sets the progress bar maximum value within the dialog displayed while
// the associated Task is executing.
public uint Max { get; set; } Unfortunately, this class is not listed in our API Reference, I am trying to get this fixed with the next release. Below is a sample tool that i using the progress bar and changes its properties: /// <summary>
/// This tool can be used to digitize a polygon on a map and once complete
/// the tool performs a series of buffer operations with expanding buffers
/// During the buffer creation process the Progress Dialog is displayed
/// </remarks>
internal class MultiBufferTool : MapTool
{
/// <summary>
/// Constructor of BufferGeometry tool
/// </summary>
public MultiBufferTool()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Polygon;
SketchOutputMode = SketchOutputMode.Map;
}
/// <summary>
/// Constructs the value array to be passed as parameter to ExecuteToolAsync
/// Runs the Buffer tool of Analysis toolbox
/// </summary>
/// <param name="geometry"></param>
/// <returns>Geoprocessing result object as a Task</returns>
protected override async Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
uint numBuffers = 7;
// create and initialize the progress dialog
// Note: Progress dialogs are not displayed when debugging in Visual Studio
var progDlg = new ProgressDialog($@"Creating {numBuffers} buffers", "Canceled", false);
var progsrc=new CancelableProgressorSource(progDlg);
for (uint iBuffer = 1; iBuffer <= numBuffers; iBuffer++)
{
var valueArray = await QueuedTask.Run<IReadOnlyList<string>>(() =>
{
var geometries = new List<object>() { geometry };
// Creates a 100-meter buffer around the geometry object
// null indicates a default output name is used
var valueArray = Geoprocessing.MakeValueArray(geometries, null, $@"{iBuffer*100} Meters");
return valueArray;
});
progsrc.ExtendedStatus = $@"Creating buffer #: {iBuffer} of {numBuffers}";
progsrc.Value = 100 * (iBuffer-1);
progsrc.Max = 100 * numBuffers + 1;
var gpResult = await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArray, null, progsrc.Progressor);
if(gpResult.IsFailed)
{
// display error messages if the tool fails, otherwise shows the default messages
if (gpResult.Messages.Count() != 0)
{
Geoprocessing.ShowMessageBox(gpResult.Messages, progsrc.Message,
gpResult.IsFailed ?
GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);
}
else
{
MessageBox.Show($@"{progsrc.Message} failed with errorcode, check parameters.");
}
break;
}
// check if the operator cancelled
if (progsrc.CancellationTokenSource.IsCancellationRequested) break;
}
if (progsrc.CancellationTokenSource.IsCancellationRequested)
{
MessageBox.Show("The operation was cancelled.");
}
return true;
}
} The above sample code displays the progressbar like this:
... View more
05-09-2023
06:07 AM
|
0
|
0
|
1060
|
|
POST
|
Just to clarify: This behavior requires the following options setting in ArcGIS Pro: I was not able to get this to work either, i passed the question on to team. I will let you know what we find.
... View more
05-09-2023
05:42 AM
|
1
|
1
|
988
|
|
POST
|
Regarding 1. There are many opportunities for an edit operation to fail: Attribute rules, relationships, domain values, etc. I would suggest you start your debugging session with as simple as possible (i.e. only add an item with the geometry set) and if that works you can add more fields to find out when it fails. If the simple case doesn't work your geometry might be bad, or there are domain value requirements with no default values, or other attribute rules. Without code and data sample i can't help. Regarding 2: I am still not 100% sure what you're trying to accomplish, but i think you want to maintain the current feature selection (from the map) and only customize the row selection (from a table) that is done via your custom UI. If that's the case, then the solution i listed above will do the job as it doesn't affect any existing feature selection. // load the first selected feature into the inspector using the first OID from the list of object IDs
var mapMember = firstSelectionSet.Key;
var oid = firstSelectionSet.Value[0];
inspector.Load(mapMember, oid);
//Create new feature from an existing inspector (copying the feature)
var createOp = new EditOperation
{
Name = "Copy first selected row",
SelectNewFeatures = false
};
var rowToken = createOp.Create(inspector.MapMember, inspector); // inspector.ToDictionary(a => a.FieldName, a => a.CurrentValue)
if (createOp.IsEmpty)
{
MessageBox.Show($@"Record oid: {oid} in table: [{mapMember.Name}] was not duplicated");
}
else
{
var result = createOp.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
if (!result)
MessageBox.Show($@"Copying record oid: {oid} in table: [{mapMember.Name}] failed: [{createOp.ErrorMessage}]");
else
{
var newOid = rowToken.ObjectID.Value;
MessageBox.Show($@"New record oid: {newOid} in table: [{mapMember.Name}]");
// now add this record to the existing selection
(mapMember as StandaloneTable).Select(new QueryFilter() { ObjectIDs = new long[] { newOid } }, SelectionCombinationMethod.Add);
}
} The key to get the NEW row into the selection are these lines: 1. "SelectNewFeatures = false" 2. "(mapMember as StandaloneTable).Select(new QueryFilter() { ObjectIDs = new long[] { newOid } }, SelectionCombinationMethod.Add);" Now as the code says this will add the new row to the existing selected rows of my custom UI code, if i want to remove any old rows i can simply call: "(mapMember as StandaloneTable).Select(new QueryFilter() { ObjectIDs = new long[] { oldOid } }, SelectionCombinationMethod.Subtract) Or if you want to clear all records for the table that are selected in your custom UI before you make a new selection you can simply call the following before the new selection code is executed: "(mapMember as StandaloneTable).ClearSelection()" You cannot control which row is hightlighted in the Attribute tree view (the highlighted row is used for detail display).
... View more
05-08-2023
12:10 PM
|
0
|
2
|
624
|
|
POST
|
regarding the "throwing a very generic error which is Edit operation failed", can you please share the EditOperation code snippet and the screenshot of your database fields?
... View more
05-08-2023
08:03 AM
|
0
|
1
|
2120
|
|
POST
|
If your edit operation is failing, you have to debug the cause. Usually if you create new records the cause is invalid attribute column names, or the attribute column value is either bad or has an incompatible data type. Examine the error message of the edit operation to get some idea on what went wrong. As for your selection question: I am not clear what use case you are asking for. For example: Let's say there are two rows in your target FeatureClass (or StandAloneTable) selected like in the example below (OID 1 and 3 are selected): Now comes your edit operation and creates one new row. From here there are multiple options, which one do you try to implement? 1) the new row (OID 5) is added to the existing selection: 2) the new row (OID 5) becomes the only selected row in the selection:
... View more
05-05-2023
09:06 AM
|
0
|
1
|
2149
|
|
POST
|
This works fine with StandaloneTables as well: Code snippet: try
{
QueuedTask.Run(() =>
{
// get the currently selected features in the map
var selectedFeatures = MapView.Active.Map.GetSelection();
// get the first table and its corresponding selected feature OIDs
var firstSelectionSet = selectedFeatures.ToDictionary().First(sel => sel.Key is StandaloneTable);
// create an instance of the inspector class
var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();
// load the first selected feature into the inspector using the first OID from the list of object IDs
var mapMember = firstSelectionSet.Key;
var oid = firstSelectionSet.Value[0];
inspector.Load(mapMember, oid);
//Create new feature from an existing inspector (copying the feature)
var createOp = new EditOperation
{
Name = "Copy first selected row",
SelectNewFeatures = false
};
var rowToken = createOp.Create(inspector.MapMember, inspector); // inspector.ToDictionary(a => a.FieldName, a => a.CurrentValue)
if (createOp.IsEmpty)
{
MessageBox.Show($@"Record oid: {oid} in table: [{mapMember.Name}] was not duplicated");
}
else
{
var result = createOp.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
if (!result)
MessageBox.Show($@"Copying record oid: {oid} in table: [{mapMember.Name}] failed: [{createOp.ErrorMessage}]");
else
{
var newOid = rowToken.ObjectID.Value;
MessageBox.Show($@"New record oid: {newOid} in table: [{mapMember.Name}]");
// now add this record to the existing selection
(mapMember as StandaloneTable).Select(new QueryFilter() { ObjectIDs = new long[] { newOid } }, SelectionCombinationMethod.Add);
}
}
});
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
... View more
05-04-2023
12:56 PM
|
0
|
1
|
2164
|
|
POST
|
Using 'SelectNewFeatures = true' doesn't retain any previous selections, so you have to set the EditOperation.SelectNewFeatures to false. Instead, you can use the RowToken returned by the Create method to get the newly created object id. Later you can use the RowToken.ObjectId.Value to add the newly created record to the existing selection. The snipped below works for FeatureClasses: try
{
await QueuedTask.Run(() =>
{
// get the currently selected features in the map
var selectedFeatures = MapView.Active.Map.GetSelection();
// get the first layer and its corresponding selected feature OIDs
var firstSelectionSet = selectedFeatures.ToDictionary().First();
// create an instance of the inspector class
var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();
// load the first selected feature into the inspector using the first OID from the list of object IDs
var mapMember = firstSelectionSet.Key;
var oid = firstSelectionSet.Value[0];
inspector.Load(mapMember, oid);
//Create new feature from an existing inspector (copying the feature)
var createOp = new EditOperation
{
Name = "Copy first selected feature",
SelectNewFeatures = false
};
var rowToken = createOp.Create(inspector.MapMember, inspector); // inspector.ToDictionary(a => a.FieldName, a => a.CurrentValue)
if (createOp.IsEmpty)
{
MessageBox.Show($@"Record oid: {oid} in layer: [{mapMember.Name}] was not duplicated");
}
else
{
var result = createOp.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
if (!result)
MessageBox.Show($@"Copying record oid: {oid} in layer: [{mapMember.Name}] failed: [{createOp.ErrorMessage}]");
else
{
var newOid = rowToken.ObjectID.Value;
MessageBox.Show($@"New record oid: {newOid} in layer: [{mapMember.Name}]");
// now add this record to the existing selection
(mapMember as BasicFeatureLayer).Select(new QueryFilter() { ObjectIDs = new long[] { newOid } }, SelectionCombinationMethod.Add);
}
}
});
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
} I will try the standalone table and see if that makes a difference.
... View more
05-04-2023
12:17 PM
|
0
|
0
|
2165
|
|
POST
|
Not sure if you are aware of this, but you can do this with out-of-box ArcGIS Pro features. You can create your own symbols (from images) as described here: Create or modify symbol images—ArcGIS Pro | Documentation Then you can enable the 'Unique Values' renderer to display the images using an attribute in your shapefile or geodatabase. To display any text (text from an attribute column) you can turn on labelling for that column. I used the community sample data: "Interacting with Maps.aprx" for the screenshot below:
... View more
05-02-2023
08:47 AM
|
1
|
1
|
1559
|
|
POST
|
Did you see the following build server setup documentation: ProConcepts Advanced Topics · Esri/arcgis-pro-sdk Wiki (github.com)
... View more
05-02-2023
07:35 AM
|
1
|
1
|
1253
|
|
POST
|
@marco_vertigis the developer is not able to duplicate your issue using the following code snippet in an add-in: return QueuedTask.Run(() =>
{
var map = MapView.Active.Map;
var mapDef = map.GetDefinition();
var json = mapDef.DatumTransforms[0].GeoTransformation.ToJson();
}); Can you send us a .mapx? We don’t need the actual data, so it’s OK if the layer connections are all broken. Maybe the cause is data related. You can use the 'Esri Communities' messages to keep the mapx confidential. Thanks, Wolf
... View more
05-01-2023
11:27 AM
|
0
|
1
|
1450
|
|
POST
|
Hi Kelby, I think i found the problem in the TimerTick state machine code. The variable _mapViewLoaded was not properly cleared before subscribing to the 'ActiveMapViewChanged' event. I attached the fixed code. This code is also using the ArcGIS Pro event logger. To start the Pro diagnostic monitor you can use the Ctrl+Alt+M key sequence to start it, or the /enablediagnostics command line switch (see ProGuide Command line switches for ArcGISPro.exe · Esri/arcgis-pro-sdk Wiki (github.com) ) Make sure to filter by 'ProcessProjectFiles' when viewing the log. Anyways this attached add-in's version's start machine should work as required.
... View more
04-28-2023
11:06 AM
|
0
|
1
|
494
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | Monday | |
| 1 | 07-30-2025 12:03 PM | |
| 1 | 10-06-2025 01:19 PM | |
| 1 | 10-06-2025 10:37 AM | |
| 1 | 09-24-2025 09:12 AM |
| Online Status |
Online
|
| Date Last Visited |
Wednesday
|