|
POST
|
The aptx file is usually loaded into the Pro as a projec, use the layout template for a map layout. You can use code to use the 'current active map' as the primary may shown in the newly created layout template. Recall templates can have 'tags' for text items, this means you can search for them an replace the text as well (e.g., in this example we have map layout template with Title1, subtitle1, Title2, subtitle2, etc. tags that get populated form a form) prior to executing the LoadLayoutTemplate sub. internal static void LoadLayoutTemplate(string myMapTemplatePath, string lytTitle1, string lytTitle2, string lytSubTitle1, string lytSubTitle2, string lytDateInfo, string lytDataSource, Map lytMap, Envelope lytEnvelope) { // Load WSDOT Layout templates, added as a Tool at ArcGIS Pro 2.9. try { IProjectItem myItem = ItemFactory.Instance.Create(@myMapTemplatePath, ItemFactory.ItemType.PathItem) as IProjectItem; IProjectMultiItem myMultiItem = myItem as IProjectMultiItem; LoadNewLayoutItem(myMultiItem, lytTitle1, lytTitle2, lytSubTitle1, lytSubTitle2, lytDateInfo, lytDataSource, lytMap, lytEnvelope); } catch (Exception eX) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Unable to Load requested Layout template ( internal static void LoadLayoutTemplate(string myMapTemplatePath, string lytTitle1, string lytTitle2, string lytSubTitle1, string lytSubTitle2, string lytDateInfo, string lytDataSource, Map lytMap, Envelope lytEnvelope) { // Load WSDOT Layout templates, added as a Tool at ArcGIS Pro 2.6. try { IProjectItem myItem = ItemFactory.Instance.Create(@myMapTemplatePath, ItemFactory.ItemType.PathItem) as IProjectItem; IProjectMultiItem myMultiItem = myItem as IProjectMultiItem; LoadNewLayoutItem(myMultiItem, lytTitle1, lytTitle2, lytSubTitle1, lytSubTitle2, lytDateInfo, lytDataSource, lytMap, lytEnvelope); } catch (Exception eX) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Unable to Load requested Layout template (pagx). " + eX.ToString(),"Information",0); } } public async static void LoadNewLayoutItem(IProjectMultiItem theItem, string lytTitle1, string lytTitle2, string lytSubTitle1, string lytSubTitle2, string lytDateInfo, string lytDataSource, Map lytMap, Envelope lytEnvelope) { //add the newly project item to the current project; must be public to avoid threading errors! try { //add the layout to the project and wait for import to complete await QueuedTask.Run(() => Project.Current.ImportItem(theItem, true)); //wait 1 econdto ensure we are Ready await Task.Delay(1000); // Reference the new active layout in the project LayoutView lytView = LayoutView.Active; if (lytView != null) { await QueuedTask.Run(() => { Layout myLayout = lytView.Layout; // set the text elements based on values passed from frmLayouts // help at https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/index.html#topic11176.html // https://github.com/Esri/arcgis-pro-sdk/blob/master/Examples/Layouts/MethodSnippets.cs TextElement txtTitles = myLayout.FindElement("Title1") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytTitle1, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } txtTitles = myLayout.FindElement("Title2") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytTitle2, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } txtTitles = myLayout.FindElement("SubTitle1") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytSubTitle1, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } txtTitles = myLayout.FindElement("SubTitle2") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytSubTitle2, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } txtTitles = myLayout.FindElement("DateInfo") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytDateInfo, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } txtTitles = myLayout.FindElement("DataSource") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytDataSource, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } MapFrame frameMap = myLayout.FindElement("Layers Map Frame") as MapFrame; if (frameMap != null) { //Update the MapFrame to use the Map that was active when the tool was run; set layout map element envelope based on the active map (added 1/28/2022) if (lytMap != null) { frameMap.SetMap(lytMap); frameMap.SetCamera(lytEnvelope); } } }); } } catch (Exception eX) { //do nothing ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("System Error: " + eX.ToString(), "Error",0); } } ). " + eX.ToString(),"Information",0); } } public async static void LoadNewLayoutItem(IProjectMultiItem theItem, string lytTitle1, string lytTitle2, string lytSubTitle1, string lytSubTitle2, string lytDateInfo, string lytDataSource, Map lytMap, Envelope lytEnvelope) { //add the newly project item to the current project; must be public to avoid threading errors! try { //add the layout to the project and wait for import to complete await QueuedTask.Run(() => Project.Current.ImportItem(theItem, true)); //wait 1 econdto ensure we are Ready await Task.Delay(1000); // Reference the new active layout in the project LayoutView lytView = LayoutView.Active; if (lytView != null) { await QueuedTask.Run(() => { Layout myLayout = lytView.Layout; // set the text elements based on values passed from frmLayouts // help at https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/index.html#topic11176.html // https://github.com/Esri/arcgis-pro-sdk/blob/master/Examples/Layouts/MethodSnippets.cs TextElement txtTitles = myLayout.FindElement("Title1") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytTitle1, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } txtTitles = myLayout.FindElement("Title2") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytTitle2, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } txtTitles = myLayout.FindElement("SubTitle1") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytSubTitle1, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } txtTitles = myLayout.FindElement("SubTitle2") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytSubTitle2, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } txtTitles = myLayout.FindElement("DateInfo") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytDateInfo, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } txtTitles = myLayout.FindElement("DataSource") as TextElement; if (txtTitles != null) { TextProperties txtProp = new TextProperties(lytDataSource, txtTitles.TextProperties.Font, txtTitles.TextProperties.FontSize, txtTitles.TextProperties.FontStyle); txtTitles.SetTextProperties(txtProp); } MapFrame frameMap = myLayout.FindElement("Layers Map Frame") as MapFrame; if (frameMap != null) { //Update the MapFrame to use the Map that was active when the tool was run; set layout map element envelope based on the active map (added 1/28/2022) if (lytMap != null) { frameMap.SetMap(lytMap); frameMap.SetCamera(lytEnvelope); } } }); } } catch (Exception eX) { //do nothing ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("System Error: " + eX.ToString(), "Error",0); } }
... View more
04-24-2023
11:32 AM
|
0
|
0
|
910
|
|
POST
|
The desktopVersion is the lowest Pro version you would like to support in your Add-In.
... View more
04-18-2023
02:04 PM
|
0
|
0
|
2379
|
|
POST
|
All 2.0 add-ins will load in any 2.x version of ArcGIS Pro so you don't have to rebuild the Add-In for every release. Version 3.0 is a breaking change and will require refactoring since it uses .Net 6 vs. Framework .Net 4.8. Key controlling factor is the settings in our config.daml file. The version number shown should always be 2.0 for Add-Ins for that major release. <ArcGIS defaultAssembly="BasicMapTool2.dll" defaultNamespace="BasicMapTool2" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
<AddInInfo id="{aa226987-8efd-4d34-b606-3e731c8cd2ff}" version="2.0" desktopVersion="2.9.0">
<Name>MapCoordinatesTool</Name> After I updated this to run under ArcGIS Pro 3.x the second line became: <AddInInfo id="{aa226987-8efd-4d34-b606-3e731c8cd2ff}" version="3.0" desktopVersion="3.0.3.36057">
... View more
04-18-2023
01:53 PM
|
0
|
3
|
2384
|
|
POST
|
You had asked about clearing the graphics layer on closing the tool. I use a clearGraphics() overlay function that is called when the user clicks the Close button on the form Or changes to another tool. You can catch the Deactivate event by adding this code in your primary namespace (i.e., the same module where you will find the OnToolActivateAsync() procedure). protected override Task OnToolDeactivateAsync(bool hasMapViewChanged)
{
clearGraphics();
return base.OnToolDeactivateAsync(hasMapViewChanged);
}
... View more
04-18-2023
09:00 AM
|
0
|
0
|
2261
|
|
POST
|
This is actually one of the simpler properties you can get from the map since you do not have to be async or queuedTask.Run. See Map Class—ArcGIS Pro var myMap = MapView.Active; SpatialReference mySpatialReference = mapView.Map.SpatialReference; if (mySpatialReference.GcsWkid == 3857) //if web Mercator then { //do some work }
... View more
04-12-2023
03:11 PM
|
0
|
1
|
2900
|
|
POST
|
You might check your namespaces, there is a new OnSelectionChange() method added at Version 3.0 to ArcGIS.desktop.Framework.Contracts and System.Windows.Controls.Primitives that is available for several of the controls (e.g., SearchTextBox,, ComboBox, etc.). These were not available at 2.9 and prior. They could be 'masking' your call. Do you need a override modifier? The override modifier is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.
... View more
04-11-2023
09:30 AM
|
0
|
3
|
1674
|
|
POST
|
Just a comment regarding Visual Studio 2022. The new version of VS treats many 'warning' messages as errors that stop a build. In VS these same issues were treated as warnings or informational only so you still could get a clean build. Check the error messages and see if you can change your build settings to ignore XDG0005 -them if they appear in consequential.
... View more
04-11-2023
09:15 AM
|
0
|
1
|
2851
|
|
POST
|
To control the color like you describe you may need to build your own FoldierLocator dialog and use the showdialog() command to open it. If you create your own form there is a BackColor property you can use. You would call the following Subroutined after instantiating the form but Before showing it. In this example I've stored my desired Form color in the myAppColor environment variable. I've used 'Named' colors as available from the SystemColors collection. Sub setControlColor(ByRef theForm As System.Windows.Forms.Form)
Dim theControl As Control
Try
theForm.BackColor = My.Settings.Default.myAppColor
Catch eX As Exception
'unable to get the color
theForm.BackColor = SystemColors.Control
End Try
For Each theControl In theForm.Controls
If theControl.GetType Is GetType(TextBox) Then
'do nothing since we want white backgrounds in our text box
Else
theControl.BackColor = My.Settings.Default.myAppColor
theControl.Invalidate()
End If
If theControl.GetType Is GetType(System.Windows.Forms.Button) Then
Dim theButton As System.Windows.Forms.Button
theButton = theControl
theButton.UseVisualStyleBackColor = False
End If
Next
theForm.Refresh()
End Sub
... View more
04-10-2023
03:11 PM
|
0
|
0
|
1494
|
|
POST
|
Since you converted the MXDs to aprx why are you surprised that the default map is not 'open'? Go to the Catalog View pane, map folder, and open the map from there. To do it programmatically you would need to grab the map document collection then, since you know there is only one map, you could do something like map[[0].open(). Otherwise you would need to search the collection by Name.
... View more
04-05-2023
02:14 PM
|
0
|
1
|
5289
|
|
POST
|
if your always getting null, you should check that you have Activated the tab your button is on. FrameworkApplication.ActivateTab('esri_mapping_homeTab'); One activated you execute the button with command..Execute() as you show.
... View more
03-16-2023
02:17 PM
|
0
|
0
|
3150
|
|
POST
|
Prior to upgrading your add-In project to .Net 6 and ArcGIS Pro 3.x, you should upgrade Pro on the developer machine to your target Pro version. Secondly, your SDK version needs to match the Pro target. If you are pulling the SDK from the web it will get the 'newest' SDK by default, which is now Pro 3.1. If you need Pro 3.0 SDK then a manual install of the SDK from ESRI downloads site is required. Look in Project Properties and Build Configuration to update .Net Framework versions. I also had to update csproj as describe above. <?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net6.0-windows</TargetFramework> <RuntimeIdentifier>win10-x64</RuntimeIdentifier> Don't forget to update your Config.DAML! <?xml version="1.0" encoding="utf-8"?> <ArcGIS defaultAssembly="GISWorkbenchPro3.dll" defaultNamespace="GISWorkbenchPro3" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd"> <AddInInfo id="{8e190f33-95f2-4249-ae7d-bcfa45a44e72}" version="3.0" desktopVersion="3.0.3.36057">
... View more
03-15-2023
10:21 AM
|
0
|
0
|
2161
|
|
IDEA
|
The Export Training Data tool is long running. Currently the status bar will report 100% complete then take one hour to 3 days to complete writing files. This results in users restarting their computer or running out of disk space during the image chip creation process (which appears to happen AFTER the % done is at 100%). An 'Estimate Training Data Creation Time' tool is needed AND the status bar needs to be more representative of the actual time required to process the data.
... View more
03-15-2023
09:35 AM
|
3
|
1
|
1926
|
|
POST
|
Have you considered using a Map Layout Template (.pagx file extension) that would contain the custom definitions you need? The legend, labels, symbols, etc. can be given unique tags/names so they can be updated in code. In our case we have a user select from a list of templates in a form and then enter titles (on the form). When they click Apply the selected template is loaded with the current ActiveMap in the frame and the maps titles (defined in the template) are automatically updated. *Layout files (.pagx file extension) are saved layouts that can be shared across projects. They can be used as a template for new projects and can create consistency across a set of layouts or throughout an organization.
... View more
03-08-2023
09:47 AM
|
0
|
0
|
4913
|
|
POST
|
No, if you update the Config.daml date and have edited at least one form or module it should work. However, if it does not then you need to do a Clean Solution | Rebuild Solution to pick-up your changes. Visual Studio 2019 was better than 2022 in doing complete builds. VS 2022 try's to be Smart and will not rebuild a file if it thinks the Resources have not changed. Unfortunately, for an ArcGIS Pro Add-In this does not result in the desired behavior.
... View more
03-07-2023
01:44 PM
|
2
|
0
|
2304
|
| Title | Kudos | Posted |
|---|---|---|
| 8 | 3 weeks ago | |
| 1 | 4 weeks ago | |
| 1 | 06-17-2026 08:21 AM | |
| 1 | 06-15-2026 08:41 AM | |
| 1 | 06-10-2026 08:40 AM |
| Online Status |
Offline
|
| Date Last Visited |
Thursday
|