|
POST
|
Unfortunately, there is only a general error message for this type of failure. We are still checking if this is a potential bug. What i see in my test add-in is that i can set the value only if the value is different. For example: if your ID field already has a value of '5' i can't perform the update by writing a new value of '5', instead that would cause the 'operation failed' error. However, i can write a value of '6'. In my sample snippet below i write a time string that changes every minute, but i can't write the new value unless it's different. This is a work around you can use since IsEmpty is true if no values have changed: if (!assignIDEditOp.IsEmpty) { // write the new value .... var isOK = assignIDEditOp.Execute(); ... } The sample snippet is for 2.9, protected override void OnClick()
{
var pLay = MapView.Active?.Map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>().Where(r => r.Name == "TestPoints")
.FirstOrDefault();
if (pLay == null) return;
var updateId = 5;
QueuedTask.Run(() =>
{
EditOperation assignIDEditOp = new EditOperation
{
Name = "assignIDEditOp",
SelectModifiedFeatures = false,
SelectNewFeatures = false
};
var strID = $@"ID={DateTime.Now.ToShortTimeString()}";
var pInsp = new Inspector(true); // 3.0 doesn't need isFeatureEditing: true anymore
pInsp.Load(pLay, 5);
{
pInsp["TheString"] = strID;
assignIDEditOp.Modify(pInsp);
if (!assignIDEditOp.IsEmpty)
{
var isOK = assignIDEditOp.Execute();
if (!isOK)
{
MessageBox.Show(assignIDEditOp.ErrorMessage);
}
}
}
});
} It turns out that there's a previous post about this issue: https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-failed/m-p/1178371#M8204
... View more
07-20-2022
03:20 PM
|
0
|
1
|
941
|
|
POST
|
Ok, got it ... the screenshot helps. So the problem is that you do a 'select all' and only items in the visible range of the listbox are selected? I think that's a newly introduced bug in WPF (or maybe an 'optimization'). I would suggest two possible solutions: Try the following in your listbox definition: <ListBox VirtualizingStackPanel.IsVirtualizing="False" ... /> Or when you 'select' all items loop manually through the list and set 'IsSelected' for each item in the list. Let me know if this doesn't work and i enhance my test app to duplicate the issue.
... View more
07-20-2022
08:39 AM
|
0
|
1
|
5223
|
|
POST
|
I couldn't quite figure out what you were trying to do, but if you are populating a list and creating layers from the selection (checkbox) on that list like shown below, i simplified your code a bit: the simplified XAML looks like this: <ListBox Grid.Row="0" Margin="5" ItemsSource="{Binding MyLayers}"
ItemContainerStyle="{DynamicResource Esri_ListBoxItemHighlightBrush}"
SelectedItem="{Binding MyLayersSelection}"
BorderBrush="{DynamicResource Esri_TextControlBrush}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsChecked}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox> and the code behind looks like this: private ObservableCollection<MyLayer> _myLayers = new ObservableCollection<MyLayer>();
/// <summary>
/// This is the list of MyLayer objects
/// </summary>
public ObservableCollection<MyLayer> MyLayers
{
get { return _myLayers; }
set
{
SetProperty(ref _myLayers, value, () => MyLayers);
}
} i attached my 3.0 test add-in. If you need to act upon individual checkbox changed events the MyLayer class has to implement INotifyPropertyChanged.
... View more
07-20-2022
07:59 AM
|
1
|
2
|
5228
|
|
POST
|
If the AddIn builds without errors and it still doesn't work, you should debug the addin with the following Exceptions Settings for "Common Language Runtime" checked (to get the Exception Settings dockpane in Visual Studio you click on "Debug" | "Windows" | "Exceptions Settings"). If you don't get any exceptions when debugging or you can't figure out the cause for the exception, send us the code snippet that doesn't work anymore (the sending of the features) so we can take a look at it. In the past i found that many times the cause of such problems is that API code is not running from within the context of QueuedTask.Run(). See more here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Asynchronous-Programming-in-ArcGIS-Pro#threads-in-arcgis-pro If your Addin buttons stay disabled when you first click a button, that's usually a sign that the Pro API Framework cannot find your executable (did you rename the Dll?) or some code in your constructors throw an exception in which case the debugging steps above will help.
... View more
07-19-2022
06:38 AM
|
2
|
2
|
4797
|
|
POST
|
Below is a sample snippet and the method you're looking for is: CreateCIMCalloutTextGraphic(cityName, geometry) which takes a string followed by a geometry (where the leader line ends). The sample is taken from a 2022 Palm Springs Dev Summit tech session, which you can get here: https://github.com/esri/arcgis-pro-sdk/wiki/tech-sessions and then click on "Using Graphic Elements with Maps and Layouts" under 2022 Palm Springs. Note that this sample in 2.x so you would have to convert this to 3.0. internal class AddCalloutText : Button
{
private List<IDisposable> _graphics = new List<IDisposable>();
protected override void OnClick()
{
try
{
if (_graphics.Count() > 0)
{
// clear existing graphic
foreach (var graphic in _graphics)
graphic.Dispose();
_graphics.Clear();
return;
}
QueuedTask.Run(() =>
{
Envelope zoomExtent;
var cityName = "Redlands";
var geometry = Module1.GetGeometry("U.S. Cities", $@"city_name = '{cityName}'"); // USHighways, route_num = 'I10' States, state_name = 'California'
var cimGraphic = CreateCIMCalloutTextGraphic(cityName, geometry);
var graphic = MapView.Active.AddOverlay(cimGraphic);
_graphics.Add(graphic);
zoomExtent = geometry.Extent;
cityName = "Palm Springs";
geometry = Module1.GetGeometry("U.S. Cities", $@"city_name = '{cityName}'");
cimGraphic = CreateCIMCalloutTextGraphic(cityName, geometry);
graphic = MapView.Active.AddOverlay(cimGraphic);
_graphics.Add(graphic);
zoomExtent = zoomExtent.Union(geometry.Extent);
MapView.Active.ZoomTo(zoomExtent.Expand(1.5, 1.5, true), new TimeSpan(0, 0, 1));
});
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private static CIMTextGraphic CreateCIMCalloutTextGraphic(string text, Geometry geometry)
{
var textSymbolRef = SymbolFactory.Instance.ConstructTextSymbol(
ColorFactory.Instance.BlackRGB, 10, "Tahoma", "Bold").MakeSymbolReference();
//now set text and location for the CIMGraphic
var textGraphic = new CIMTextGraphic
{
Symbol = textSymbolRef,
Text = text,
Shape = geometry
};
textGraphic.Placement = Anchor.BottomLeftCorner;
//Create a call out
var backgroundCalloutSymbol = new CIMBackgroundCallout();
// set callout colors and leader line
#region callout colors and leader line
//colors used by bounding callout box
CIMColor accentColor = CIMColor.CreateRGBColor(0, 255, 0);
CIMColor backgroundColor = ColorFactory.Instance.CreateRGBColor(190, 255, 190, 50);
//Leader line
//Get a line symbol
var lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(accentColor, 2, SimpleLineStyle.Solid);
//Create a solid fill polygon symbol for the callout.
var polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol(backgroundColor, SimpleFillStyle.Solid);
//accent symbol
var accentSymbol = SymbolFactory.Instance.ConstructLineSymbol(accentColor, 2, SimpleLineStyle.Solid);
//assign the leader line to the callout
backgroundCalloutSymbol.LeaderLineSymbol = lineSymbol;
backgroundCalloutSymbol.LineStyle = LeaderLineStyle.Base;
backgroundCalloutSymbol.LeaderOffset = 2;
//Assign the polygon to the background callout
backgroundCalloutSymbol.BackgroundSymbol = polySymbol;
//Set margins for the callout to center the text
backgroundCalloutSymbol.Margin = new CIMTextMargin
{
Left = 5,
Right = 5,
Top = 5,
Bottom = 5
};
//define the Accent bar
backgroundCalloutSymbol.AccentBarSymbol = accentSymbol;
#endregion callout colors and leader line
//change the Offset for the textbox ... move 20 right and 20 high
var textSym = textGraphic.Symbol.Symbol as CIMTextSymbol;
textSym.OffsetX = 20;
textSym.OffsetY = -40;
//assign the callout to the textSymbol
textSym.Callout = backgroundCalloutSymbol;
if (geometry.GeometryType == GeometryType.Point)
{
// create a leader point
CIMLeaderPoint leaderPt = new CIMLeaderPoint
{
Point = geometry as MapPoint
};
// assign to the textGraphic
textGraphic.Leaders = new List<CIMLeader>() { leaderPt }.ToArray();
}
return textGraphic;
}
}
... View more
07-18-2022
06:34 AM
|
0
|
2
|
2129
|
|
POST
|
Thanks for your diligence on this issue. Also @UmaHarano wanted me to let you know that the API now has the AddInInfo Class You can retrieve the list of all AddInInfos using FrameworkApplication.GetAddInInfos() Using your GetAddInId() helper method allows to select the AddInInfo object for the running AddIn - here is the sample code for getting an AddInInfo instance for the running AddIn: protected override void OnClick()
{
try
{
// get the ID of this Addin
var myAddinGuid = GetAddInGuid();
var addinInfos = FrameworkApplication.GetAddInInfos();
var myAddin = addinInfos.Where(x => x.ID == myAddinGuid).FirstOrDefault();
if (myAddin != null)
{
MessageBox.Show(GetAddInInfoDetail(myAddin));
}
else
throw new Exception("Can't find Addin Guid");
}
catch (Exception ex)
{
MessageBox.Show($@"Error: {ex.ToString()}");
}
}
private static string GetAddInInfoDetail(AddInInfo info)
{
StringBuilder sb = new();
sb.AppendLine($"Addin: {info.Name}");
sb.AppendLine($"Description {info.Description}");
sb.AppendLine($"ImagePath {info.ImagePath}");
sb.AppendLine($"Author {info.Author}");
sb.AppendLine($"Company {info.Company}");
sb.AppendLine($"Date {info.Date}");
sb.AppendLine($"Version {info.Version}");
sb.AppendLine($"FullPath {info.FullPath}");
sb.AppendLine($"DigitalSignature {info.DigitalSignature}");
sb.AppendLine($"IsCompatible {info.IsCompatible}");
sb.AppendLine($"IsDeleted {info.IsDeleted}");
sb.AppendLine($"TargetVersion {info.TargetVersion}");
sb.AppendLine($"ErrorMsg {info.ErrorMsg}");
sb.AppendLine($"ID {info.ID}");
sb.AppendLine("");
return sb.ToString();
}
private static string GetAddInGuid()
{
// get the GUID that identifies the current add-in
Assembly exAssembly = Assembly.GetExecutingAssembly();
var dirs = exAssembly.Location.Split(System.IO.Path.DirectorySeparatorChar);
if (dirs.Length > 2
&& Guid.TryParse(dirs[dirs.Length - 2], out Guid assemblyGuid))
{
return $@"{{{assemblyGuid.ToString()}}}";
}
throw new Exception($@"Assembly path doesn't contain a GUID: {exAssembly.Location}");
}
... View more
07-15-2022
07:30 AM
|
1
|
1
|
2031
|
|
POST
|
Unfortunately, the SDK does not have field mapping objects like python. This and better Pro SDK for .Net suited documentation and sample usage code has been (and still is) on the Pro SDK team's wish list for a while. If I remember correctly the example above (references in the 'bug' report) worked fine for geodatabases (file, etc.) but not for shapefiles. Are you trying read/write to a shapefile? I noticed that the 'bug' thread you mentioned above was never solved, I will reach out to Nobbir and find out where we left off. However, if you are just trying to copy / append data to a geodatabase the sample snippet should work. We also now have DDL support in the API: ProConcepts DDL · Esri/arcgis-pro-sdk Wiki (github.com) which will allow you to inspect the schema of existing tables/feature classes. However, DDL support is also limited to Geodatabases only. Let me know what you try to do. You can also reach out to me at: wkaiser@esri.com if you want to keep samples/data confidential.
... View more
07-15-2022
06:47 AM
|
0
|
0
|
2763
|
|
POST
|
I tried this method on both 2.x migrated projects and 3.0 created addin projects. There might be a better way to do this but for the time being this should work: public static string GetAddInGuid()
{
// get the GUID that identifies the current add-in
Assembly exAssembly = Assembly.GetExecutingAssembly();
var dirs = exAssembly.Location.Split(System.IO.Path.DirectorySeparatorChar);
if (dirs.Length > 2
&& Guid.TryParse(dirs[dirs.Length - 2], out Guid assemblyGuid))
{
return assemblyGuid.ToString();
}
throw new Exception($@"Assembly path doesn't contain a GUID: {exAssembly.Location}");
}
... View more
07-14-2022
09:45 AM
|
0
|
2
|
4842
|
|
POST
|
I am still looking at this issue. I was able to duplicate the difference in behavior between an Addin that is migrated to 3.0 and an Addin that is built with 3.0. When migrating to 3.0 the migration process retains the existing AssemblyInfo.cs file (where the Assembly Guid attribute is set) and then sets the tag "GenerateAssemblyInfo" in the project file to false (false means the AssemblyInfo is used instead of auto generated assembly info). After migrating a project to 3.0 the Assembly Guid attribute is extracted from the migrated AssemblyInfo.cs (in essence this works just like in 2.x). This doesn't happen when creating a new project using the Addin project template because it is using the .Net default (which is: GenerateAssemblyInfo = true) which doesn't create the assembly info source and apparently doesn't generate an Assembly Guid attribute. I am trying to find another way to get the Guid. As a workaround you could change the project file and add this under the first PropertyGroup tag: <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
and then add a n AssemblyInfo.cs file under the project's Properties folder (use and modify an AssemblyInfo.cs file from community samples).
... View more
07-14-2022
08:42 AM
|
0
|
1
|
2054
|
|
POST
|
@AbelPerez , it appears that the AddinInfoManager sample was missing when we published the 3.0 community samples. Sorry about that, but i added a 3.0 version of the sample and it appeared to work for me. arcgis-pro-sdk-community-samples/Content/AddInInfoManager at master · Esri/arcgis-pro-sdk-community-samples (github.com)
... View more
07-12-2022
01:19 PM
|
0
|
0
|
2872
|
|
POST
|
I made up the sample that you see above to show that one can add different types of columns to a file geodatabase. If I remember correctly the bug had to do with adding columns to a shapefile.
... View more
07-12-2022
12:36 PM
|
0
|
1
|
2786
|
|
POST
|
You can go to "Releases" (on the ArcGIS Pro SDK Community Samples GitHub home page on the right side below the 'About' section): Releases · Esri/arcgis-pro-sdk-community-samples (github.com) Go to the release you want to work with and download (under assets) the sample data you like to work with and the source code. If you clone the repo in Visual Studio you can change the GitHub branch to the release you like to work with, however, you will still have to download the corresponding datasets from the Release (see above).
... View more
07-12-2022
11:21 AM
|
0
|
1
|
2071
|
|
POST
|
You can also look at this example (from community samples) which is using the Microsoft.Data.SqlClient NuGet in its plug-in project: ProSqlExpressReader solution I recommend searching the community samples GitHub repository for the specific class that you want to use, in this case I searched for "SqlConnection" and you will get a hit if samples are using that class.
... View more
07-12-2022
09:51 AM
|
0
|
0
|
9917
|
|
POST
|
Ok, that explains it. I guess the Migation guide ( ProConcepts-3.0-Migration-Guide ) in the ArcGIS Pro SDK wiki could be a bit more frontline and center.
... View more
07-12-2022
07:03 AM
|
0
|
0
|
1214
|
|
POST
|
Looking at the complexity of your query forms it looks like the best way would be to use a ProWindow. You could use the tabcontrol that i showed in my Dockpane sample to put all your search forms into the same ProWindow, but i would definitely recommend switching to an MVVM based ProWindow. There was a tech session at the 2022 Dev Summit that discussed ProWindow vs. Dockpane and assync processing and that might be helpful to you: Tech Sessions · Esri/arcgis-pro-sdk Wiki (github.com) click on "Improving Your Dockpane and ProWindow Design Patterns" in order to get the slides and code samples (in 2.x). There might even be a video of this session available on YouTube or on Esri Videos: GIS, Events, ArcGIS Products & Industries (search for "Improving Your Dockpane and ProWindow Design Patterns"). As forms get more complex (and your forms definitely fall into that category) MVVM based forms are much easier to maintain. It's a bit of a leap at first (coming from ArcMap winforms) but it will pay off in the long run.
... View more
07-11-2022
07:44 AM
|
0
|
0
|
1934
|
| 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
|