|
POST
|
Like Uma mentioned above the CreateColorizer method appears to have some issues. I looked at the colorizer result and the values[0] property in the group / classes appears to have the wrong value. I wrote a workaround to 'hand-correct' those values (i also overwrite the label - but that's extra) by using the raster's attribute table to look up the correct values - needless to say you have to adapt this code to use your raster fields: protected async override void OnClick()
{
var raster = MapView.Active.Map.GetLayersAsFlattenedList().OfType<RasterLayer>().FirstOrDefault();
if (raster == null)
return;
await QueuedTask.Run(() =>
{
string fieldName = "ericlookup"; // Landuse or value or ericLookup
var style = Project.Current.GetItems<StyleProjectItem>().First(s => s.Name == "ArcGIS Colors");
var ramps = style.SearchColorRamps("Green Blues");
var colorizerDef = new UniqueValueColorizerDefinition(fieldName, ramps[0].ColorRamp);
var colorizer = raster.CreateColorizer(colorizerDef);
// fix up colorizer ... turns out the values are wrong ... the landuse value is always inserted
// we use the Raster's attribute table to collect a dictionary with the correct replacement values
Dictionary<string, Tuple<string, string>> landuseToFieldValue = new Dictionary<string, Tuple<string, string>>(); ;
if (colorizer is CIMRasterUniqueValueColorizer uvrColorizer)
{
var rasterTbl = raster.GetRaster().GetAttributeTable();
var cursor = rasterTbl.Search();
while (cursor.MoveNext())
{
var row = cursor.Current;
var correctVal = row[fieldName].ToString();
var correctCnt = row["count_"].ToString();
var key = row[uvrColorizer.Groups[0].Heading].ToString();
landuseToFieldValue.Add(key, new Tuple<string, string>(correctVal, correctCnt));
}
uvrColorizer.Groups[0].Heading = fieldName;
for (var idxGrp = 0; idxGrp < uvrColorizer.Groups[0].Classes.Length; idxGrp++)
{
var grpClass = uvrColorizer.Groups[0].Classes[idxGrp];
var oldValue = grpClass.Values[0];
var correctValue = landuseToFieldValue[oldValue];
grpClass.Values[0] = correctValue.Item1;
grpClass.Label = $@"{correctValue.Item1} ({correctValue.Item2})";
}
}
raster.SetColorizer(colorizer);
});
}
With the workaround i was able to code against any of the fields in the raster's attribute table: Here is the default symbology after i added the raster to my map: and here are some tests using different field names:
... View more
12-19-2019
03:05 PM
|
0
|
0
|
1424
|
|
POST
|
Hi Srinu, When debugging methods like OnUpdate, that are repetitively called in the background, you cannot use MessageBox.Show or any other method that will hang the OnUpdate function. Using methods like System.Diagnostics.Debug.WriteLine as i did in my sample because these functions will not 'hang' the method and you can still see our output when looking at the Visual Studio output window. Also you cannot set breakpoints in these types of methods for the same reason. After reading your bullets 1 and 2 above, i wanted to note that you can use the ArcGIS Pro SDK Item templates to add buttons to your add-in. Pro SDK item templates will stub out all code and daml you need. See: install-arcgis-pro-sdk-for-net and ProGuide-Build-Your-First-Add-in for more details in case you are not aware of this. I attached a sample project TabShowMappane. Look at the code in the Module1 class and the two buttons (one for each tab). You need a project that has two map panes: Map1 and Map2 as shown here and click on the "Tab Map 1" tab: Not that the Map1 mapview is active. Now click on the "Tab Map2" tab: and see the active mapview change to Map2. I hope this gets you started.
... View more
12-18-2019
11:01 AM
|
1
|
1
|
4252
|
|
POST
|
Hi Barbara, you can change the load behavior in the config.daml file by using the 'autoLoad' attribute setting: <insertModule id="ProAppModule7_Module" className="Module1" autoLoad="false" caption="Module1"> setting 'autoLoad' to true will load your add-in at startup. Just note that this might prolong the startup time for ArcGIS Pro.
... View more
12-16-2019
11:00 AM
|
1
|
0
|
4574
|
|
POST
|
Hi Srinu, Unfortunately i can't find any 'out-of-box' events in the API that will help you with this. As a possible workaround i think you can override one of your UI control's OnUpdate() methods in order to trigger your code to check if the matching map pane is being displayed. Needless to say you have to implement this for one UI control on each tab. I did a sample test on a button control: internal class Button1 : Button
{
protected override void OnClick()
{
}
protected override void OnUpdate()
{
System.Diagnostics.Debug.WriteLine("Add your logic here");
base.OnUpdate();
}
} OnUpdate was called as soon as the add-in was loaded (in my case i am using JIT loading - with a module 'autoLoad=false', so my code is not executed until i click on a button or other component of my add-in). I hope this helps. - Wolf
... View more
12-16-2019
10:56 AM
|
0
|
4
|
4252
|
|
POST
|
Hi Srinu, Can you explain your desired workflow in a bit more detail? Are these ribbons or tabs you are changing defined in your add-in? There is sample code that manipulates which map views are activated from a dockpane, maybe that helps: https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Framework/OpenMapViews - Wolf
... View more
12-12-2019
12:07 PM
|
0
|
6
|
4252
|
|
POST
|
Hi Martin, Or you can implement 'custom project settings' as shown here: https://github.com/esri/arcgis-pro-sdk/wiki/ProGuide-Custom-settings - Wolf
... View more
12-12-2019
08:28 AM
|
0
|
1
|
1789
|
|
POST
|
A possible work around (I didn't try this yet): Maybe until the problem is resolved you can add the 'layout added' date as part of the LayoutProjectItem's Summary property and then parse the Summary string for the 'layout added' date as part of your removal logic.
... View more
12-10-2019
03:29 PM
|
1
|
0
|
1119
|
|
POST
|
Your assumption was correct. The dev team for the statistics class(es) is planning a fix for one of the upcoming releases. It's too late for the fix to make it into the 2.5 release though.
... View more
12-10-2019
01:58 PM
|
2
|
0
|
4744
|
|
POST
|
Also some 3rd party libraries provide methods to change load location for any dlls or subprocesses. For example i wrote a sample using CefSharp which required this initialization code before i was able to use the control: if (!Cef.IsInitialized)
{
var settings = new CefSettings()
{
//By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
CachePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"),
BrowserSubprocessPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath(Assembly.GetExecutingAssembly().Location)), "CefSharp.BrowserSubprocess.exe")
};
//Perform dependency check to make sure all relevant resources are in our output directory.
Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
}
... View more
12-06-2019
01:17 PM
|
0
|
0
|
3100
|
|
POST
|
Add these lines in your Module class (this constructor should be called first) - rename Module1 to the name of your Module class: public Module1()
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveProAssemblyPath);
}
And add this method to the module class: static System.Reflection.Assembly ResolveProAssemblyPath(object sender, ResolveEventArgs args)
{
string folderPath = System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath(System.Reflection.Assembly.GetExecutingAssembly().Location));
string assemblyPath = Path.Combine(folderPath, new System.Reflection.AssemblyName(args.Name).Name + ".dll");
if (!File.Exists(assemblyPath)) return null;
System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(assemblyPath);
return assembly;
} Set a breakpoint in the static method to make sure it gets called before your dll is loaded and double check the path. Needless to say this all depends on the loading method that is used for your 3rd party dll and only works if the load failure event is triggered.
... View more
12-06-2019
01:11 PM
|
0
|
1
|
3100
|
|
POST
|
Here is a piece of code that helps to resolve the DLL path is needed: https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-content-and-image-resources#images-as-embedded-resources
... View more
12-06-2019
10:59 AM
|
0
|
0
|
3100
|
|
POST
|
If you can't add a reference for the 3rd party DLL to your project, you can always add the DLL to your project as an 'existing item' (note: you can do that to any file type you'd like to add to your add-in payload) Make sure that the DLL's build action is set to 'Content' and 'copy to output directory' is set to 'Copy ...'. At run time, just before your add-in is executed by Pro, ArcGIS Pro will unzip the content of your add-in package as described here: https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Advanced-Topics#loading-3rd-party-assembly-references If the 3rd party DLL doesn't get loaded in ArcGIS Pro during runtime you can resolve the DLL's path by adding a handler to do so: AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveProAssemblyPath);
... View more
12-06-2019
10:52 AM
|
0
|
4
|
3100
|
|
POST
|
i copied the code snippet above from a working sample, so yes it does work on 2D maps (scale is not relevant in 3D). i don't know any way to change the behavior of the built-in ZoomInFixed/ZoomOutFixed buttons.
... View more
12-06-2019
08:57 AM
|
0
|
0
|
1499
|
|
POST
|
The cause could be the same as i mentioned above, mainly the partial renaming. It's also possible that the cause is installing ArcGIS Pro multiple times under different folders. To verify your installation simply create a new 'ArcGIS Pro Module Add-in' name it 'ButtonTest', once the project has been created right click (in solution explorer) on the project, click 'Add | New item', and choose 'ArcGIS Pro Button'. Now open the Button1 class file and set a breakpoint at the open curly for the OnClick method. Click on 'Build | Rebuild' then debug your code. Because Pro will only load your add-in when it's needed, you will see the breakpoint Warning you mentioned, however, once you go to the 'add-in' tab in Pro and click on your 'Button1' icon on the tab, your add-in DLL will be loaded and your breakpoint will be triggered. Let me know if this works for you.
... View more
12-06-2019
08:49 AM
|
1
|
0
|
4574
|
|
POST
|
Usually the cause for this type of error is that a class (i.e. your button class) or the add-in DLL were renamed without making the corresponding update in config.daml. If Pro loads your config.daml and can't find the code behind classes which are referenced in your config.daml, then any UI elements are disabled.
... View more
12-06-2019
08:26 AM
|
2
|
1
|
4574
|
| 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 |
yesterday
|