|
POST
|
Ed, I think this is what you are after: UtilityNetwork.CreateElement so, it might look something like this: var layer = map.GetLayersAsFlattenedList().OfType<UtilityNetworkLayer>().FirstOrDefault();
if (layer != null)
{
var utilityNetwork = layer.GetUtilityNetwork();
//the feature class being a network source...
var rowCursor = featureClass.Search(queryFilter);
while (rowCursor.MoveNext())
{
var currentRow = rowCursor.Current;
var currentElement = utilityNetwork.CreateElement(currentRow);
... View more
12-28-2018
09:43 AM
|
1
|
8
|
3672
|
|
POST
|
I cannot reproduce your issue in either 2.2 or our next release (not yet available) 2.3. The placement of your context.Invalidate statements are correct. Please work with ESRI tech support to resolve your issue. They will most likely need a copy of your data as well.
... View more
12-03-2018
11:23 AM
|
0
|
0
|
2547
|
|
POST
|
Flag your page as "dirty" - this.IsModified = true - this tells the property sheet that you have changes to commit. This guide might help - it does a step-by-step implementation: https://github.com/esri/arcgis-pro-sdk/wiki/ProGuide-Custom-settings
... View more
11-09-2018
08:57 AM
|
1
|
0
|
901
|
|
POST
|
The issue may also be that you are not using a non-recycling cursor. To test, access a non-recycling cursor off the feature class, not the layer.
... View more
10-29-2018
01:26 PM
|
2
|
1
|
1511
|
|
POST
|
unless you use a Condition, you must set Autoload=true in your Config.daml. Otherwise, your add-in is not loaded until your button is clicked.
... View more
10-11-2018
01:10 PM
|
0
|
2
|
1163
|
|
POST
|
Use a condition: ProConcepts-Framework#conditions-and-state sample: WorkingWithDAML Use a command filter: ProConcepts-Configurations#onexecutecommand
... View more
10-11-2018
09:23 AM
|
1
|
0
|
1259
|
|
POST
|
Look at the System.Windows.Interop.WindowInteropHelper class: https://docs.microsoft.com/en-us/dotnet/api/system.windows.interop.windowinterophelper?view=netframework-4.7.2 Pass in the WPF Window whose handle you want. Probably FrameworkApplication.Current.MainWIndow in your case.
... View more
10-01-2018
10:10 AM
|
2
|
1
|
1859
|
|
POST
|
This is how it works: 1. Make a new layout 2. Copy the layout to be "duplicated" (this is the Clone method) 3. Replace the layout URI of the copy with the URI of the new layout (in other words, the new layout acts as a placeholder) 4. Set the copy/clone back as the new layout definition Step 3 is the crucial step. I have posted the code below. I'd recommend running it in the debugger so you can grok what's going on internal class DuplicateLayout : Button
{
protected async override void OnClick() {
var layoutView = LayoutView.Active;
try {
if (layoutView?.Layout != null) {
await layoutView.Layout.Duplicate();
}
}
catch (Exception ex) {
System.Diagnostics.Debug.WriteLine(ex);
}
}
} public static class LayoutExtensions
{
public static async Task Duplicate(this Layout layout) {
if (layout == null)
throw new ArgumentNullException(nameof(layout), "layout cannot be null");
var layout_clone = await layout.CloneAsync();
FrameworkApplication.Panes.CreateLayoutPaneAsync(layout_clone);
}
public static Task<Layout> CloneAsync(this Layout layout) {
return QueuedTask.Run(() => {
return Clone(layout);
});
}
//Must be called on the QueuedTask
public static Layout Clone(this Layout layout)
{
var layout_dup = LayoutFactory.Instance.CreateLayout();
var metadata_uri = layout_dup.GetDefinition().MetadataURI;
var layout_def = layout.GetDefinition();
var layout_def_clone = layout_def.Clone() as CIMLayout;
layout_def_clone.URI = layout_dup.URI;
layout_def_clone.MetadataURI = metadata_uri;
layout_dup.SetDefinition(layout_def_clone);
return layout_dup;
}
} public static class CIMExtensions
{
public static CIMObject Clone(this CIMObject cimObject)
{
var clone = System.Activator.CreateInstance("ArcGIS.Core", cimObject.GetType().ToString()).Unwrap() as CIMObject;
var stringReader = new StringReader(cimObject.ToXml());
var xmlReader = new XmlTextReader(stringReader);
//xmlReader.MoveToContent();
clone.ReadXml(xmlReader);
xmlReader.Dispose();
return clone;
}
}
... View more
09-21-2018
09:54 AM
|
1
|
1
|
2038
|
|
POST
|
yes, you're quite right. It's (Basic) FeatureLayer.GetSelection() that returns a Selection and not Map.GetSelection().
... View more
09-07-2018
01:23 PM
|
0
|
0
|
1837
|
|
POST
|
I'd recommend calling Search on the Selection set like so: var rowcursor = selection.Search(); or even: var rowcursor = MapView.Active.Map.GetSelection().Search(); reference Selection.Search
... View more
09-07-2018
01:00 PM
|
0
|
2
|
1837
|
|
POST
|
Correct. Within the row events you must use Row.Store to apply changes. You will still have to deal with re-entrancy caused by Store.
... View more
09-06-2018
11:15 AM
|
0
|
0
|
1935
|
|
POST
|
Using the row, passed as the argument to the row event, as you illustrate above is the correct pattern. Use of the inspector to apply an edit in any of the row events should not be attempted (whether it worked previously or not).
private void RowEvent(....
//this is correct
args.Row["Shape"] = CurrentlyUpdatingGeometry;
args.Row.Store();
//this is not. It triggers another edit operation
insp["Shape"] = CurrentlyUpdatingGeometry;
insp.Apply(); //<-- attempts to execute another edit operation Note that row events are fired during the store* on the underlying geodatabase - in other words, before the store has completed but after it has started. Therefore, any changes you are applying in an edit operation (that has triggered a row event) have not yet been committed and are in flight. This is why, in most cases, they are cancel-able regardless of the transaction type (short or long). It is also why, if you re-access the row via the layer or the feature class, "in flight", you get the "original" value. *Non-versioned feature services on a create fire the row event after the store on the server. Below is a code example you can play with to test this behavior. I am running it against an editable hosted point feature service: The code creates a feature and then moves it to another location. The feature shape is output at various instances within the transaction - Before, During ("in flight"), and After. This is the output: Create location: 60546084,2112494 <-- start location
Create oid: 44
Intended Move location: 60546634,2113044 <-- what we pass to modify
INFLIGHT: Move location: 60546634.0001205,2113043.99987471 <-- from Row["SHAPE"] in event
DATABASE: Move location: 60546083.9999188,2112494.00000116 <-- from GDB in event
Final Move location: 60546634.0001205,2113043.99987471 <-- final after event (and commit)
Notice that the "move" location in the event ("INFLIGHT") within the "modify-ing" row ("args.Row" or "rc.Row" in my example), is the intended final location. Notice that the location I retrieve from the database in the event is not. It is still the "pre" location as the database has not yet been modified and will not be modified until after the execute() has concluded successfully. After execute(), re accessing the database gets the (correct) final location. internal class TestRowEvent : Button
{
private SubscriptionToken _token = null;
private double _x = 60546084.0;
private double _y = 2112494.0;
private double _delta = 550.0;
protected async override void OnClick()
{
await QueuedTask.Run(() => {
var fs_layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>()
.First(fl => fl.Name == "<name of layer here>");
var editOp = new EditOperation();
editOp.Name = $"Create {fs_layer.Name}";
editOp.SelectNewFeatures = true;
//make the locations
var pt = MapPointBuilder.CreateMapPoint(_x, _y, fs_layer.GetSpatialReference());
Dictionary<string, object> attributes = new Dictionary<string, object>();
attributes["SHAPE"] = pt;
attributes["...."] = "value 1";
//etc
long _newoid = -1;
editOp.Create(fs_layer, attributes, (oid) => _newoid = oid);
editOp.Execute();
editOp = null;
System.Diagnostics.Debug.WriteLine($"Create location: {_x},{_y}");
System.Diagnostics.Debug.WriteLine($"Create oid: {_newoid}");
//move the feature
pt = MapPointBuilder.CreateMapPoint(_x + _delta, _y + _delta, fs_layer.GetSpatialReference());
editOp = new EditOperation();
editOp.Name = $"Move {fs_layer.Name}";
editOp.SelectModifiedFeatures = true;
editOp.Modify(fs_layer, _newoid, pt);
System.Diagnostics.Debug.WriteLine($"Intended Move location: {_x + _delta},{_y + _delta}");
//show the geometry "in-flight"...
_token = ArcGIS.Desktop.Editing.Events.RowChangedEvent.Subscribe((rc) =>
{
var inflight_pt = rc.Row["SHAPE"] as MapPoint;
System.Diagnostics.Debug.WriteLine($"INFLIGHT: Move location: {inflight_pt.X},{inflight_pt.Y}");
//pull location from the database
using (var rowcursor = fs_layer.GetSelection().Search())
{
rowcursor.MoveNext();
var db_pt = rowcursor.Current["SHAPE"] as MapPoint;
System.Diagnostics.Debug.WriteLine($"DATABASE: Move location: {db_pt.X},{db_pt.Y}");
}
ArcGIS.Desktop.Editing.Events.RowChangedEvent.Unsubscribe(_token);
_token = null;
}, fs_layer.GetTable());
editOp.Execute();
//get the modified feature
var insp = new Inspector();
insp.Load(fs_layer, _newoid);
var move_pt = insp["SHAPE"] as MapPoint;
System.Diagnostics.Debug.WriteLine($"Final Move location: {move_pt.X},{move_pt.Y}");
});
}
}
... View more
09-06-2018
10:28 AM
|
0
|
0
|
1935
|
|
POST
|
Is this what you are looking for? mapView.GetViewSize()
... View more
08-31-2018
01:35 PM
|
1
|
1
|
1804
|
|
POST
|
Daniel, you need a SymbolStyleItem. The property in question is "PreviewImage" (inherited from StyleItem). So....given a symbol....how do you use a SymbolStyleItem to preview it? ...
return QueuedTask.Run(() => {
CIMSymbol symbol = ....;
var si = new SymbolStyleItem() {
Symbol = symbol,
PatchHeight = 64,
PatchWidth = 64
};
return si.PreviewImage;
}); This is a good topic for a snippet. I'll make sure one gets added.
... View more
08-02-2018
03:22 PM
|
3
|
0
|
2260
|
|
POST
|
Two things that may help: 1. When working with the CIM, I often set a line like this in my code: var str = cim.ToXML(); Then, in the debugger, I set a breakpoint on that line and now I can hover over "str" and use the text or xml viewer built in to visual studio to examine "str". [I am not sure if you realize but the CIM definition is serializable to XML]. Note that the "type" of each element is shown in the XML as well as the structure. 2. Use the CIM Viewer. It is a utility we (Pro SDK team) wrote for examining the CIM. You can find it here: arcgis-pro-sdk-cim-viewer It allows you to see the CIM definition of maps, layers, layouts, and layout elements as well as edit their xml.
... View more
06-14-2018
03:11 PM
|
1
|
0
|
2868
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-19-2026 10:29 AM | |
| 1 | 04-29-2026 02:06 PM | |
| 1 | 01-08-2026 02:03 PM | |
| 1 | 01-08-2026 02:15 PM | |
| 3 | 12-17-2025 11:33 AM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|