|
POST
|
Thank you Rich! Looking forward to the suggestions of your colleagues, and I am pretty sure, the Map.Redraw is needed in the whole process. Thomas
... View more
09-16-2020
11:31 PM
|
0
|
0
|
4343
|
|
POST
|
Hmm, since the Map.Redraw(true) does not solve the issue, do you or one of you colleagues have a suggestion on how to get the data source shift working?
... View more
09-16-2020
08:46 AM
|
0
|
3
|
4343
|
|
POST
|
Hi Rich, I did not call Map.Redraw, but I have now... Since Map.Redraw is called on the MapView object I had to switch from the Map object to MapView. Hence, selectedMapAjour is now of type MapView. The code look now as follows: if (selectedMapAjour != null && !string.IsNullOrEmpty(PathGdbAjour))
{
foreach (FeatureLayer layer in selectedMapAjour.Map.Layers.OfType<FeatureLayer>())
{
GetSetDataConnection(selectedMapAjour, layer, PathGdbAjour);
}
}
private async void GetSetDataConnection(MapView mapview, FeatureLayer layer, string newGDB)
{
await QueuedTask.Run(() =>
{
CIMFeatureLayer def = layer.GetDefinition() as CIMFeatureLayer;
var dcon = def.FeatureTable.DataConnection as CIMStandardDataConnection;
dcon.WorkspaceConnectionString = System.IO.Path.Combine(newGDB, layer.Name);
dcon.Dataset = layer.Name;
layer.SetDefinition(def);
mapview.Redraw(true);
});
} Line 18 does not change the result. When I adjust the data source for a layer manually, then I have to select the appropriate feature class within the geodatabase. Confirming the 'Change Data Source' dialogue makes the layer properties dialogue flash and thereafter the property for the database contains the path to the database. All other information of the layers data source properties are populated. The property 'Feature Class' does not only have the name of the feature class but also a button, holding information about the 'Object Class ID'. When I run my code, the property for the database in the layer property dialogue is showing the entire path, down to the feature class C:\Projects\Support\geo_507474_20200721_12_42.gdb\Bassin. The property for Feature Class in the dialogue show the name of the feature class (without the button for the 'Object Class ID'), while all other properties only show a 'Not Available'. Putting the redraw into the GetSetDataConnection method means that for every layer the map view will be redrawn. I set the redraw in there because when having it right after line 6 I am told that the redraw method must be called on the thread this object was created. Do I have to set the redraw into the GetSetDataConnection method or can I do this also at a more 'central place' where the map view is only updated once all layers got their new data source.
... View more
09-16-2020
01:43 AM
|
0
|
5
|
4343
|
|
POST
|
If the id you provided would be a DockPane (ref to "activate a TOC View") then you would do the following: DockPane pane = FrameworkApplication.DockPaneManager.Find("esri_mapping_SnappingView");
if (pane == null)
return;
pane.Activate(); I am not aware of any dockpane for snapping. Doesn't mean it's not there...
... View more
09-15-2020
07:41 AM
|
0
|
0
|
907
|
|
POST
|
I have a couple of map panes in ArcGIS Pro where the data source might differ from one occasion to te other. However, the name of the FeatureLayers are constant. I am trying to adjust the underlaying data source based on user input. Meaning, the user has an OpenItemDialog listening on geodatabases. Plan is to use the retrieved path for the update. However, I don't succeed. In the following code snippet the selectedMapAjour is of type Map if (selectedMapAjour != null && !string.IsNullOrEmpty(PathGdbAjour))
{
foreach (FeatureLayer layer in selectedMapAjour.Layers.OfType<FeatureLayer>())
{
GetSetDataConnection(layer, PathGdbAjour);
}
}
private async void GetSetDataConnection(FeatureLayer layer, string newGDB)
{
await QueuedTask.Run(() =>
{
CIMFeatureLayer def = layer.GetDefinition() as CIMFeatureLayer;
var dcon = def.FeatureTable.DataConnection as CIMStandardDataConnection;
dcon.WorkspaceConnectionString = System.IO.Path.Combine(newGDB, layer.Name);
layer.SetDefinition(def);
});
} The code runs through... only the exclamation mark in the TOC of the map do not disappear. Although, the path set via dcon.WorkspaceConnectionString is reflected in the properties of the FeatureLayers in the TOC. Hence, I am not sure if my attempt to alter the data source worked and I am missing some refresh or update call, or if this does not work at all. I basically need a C# equivalent of updateConnectionProperties. Thereafter, I will have to adjust the symbology, so ApplySymbologyFromLayer would be next. Does anybody has an example for this stuff? Best Thomas
... View more
09-15-2020
06:34 AM
|
0
|
9
|
4437
|
|
POST
|
Hi Uma, I had to check myself, and simply created a project with two empty map panes. Using the method from the original posting it identifies "Map" correctly, but "Map1" (sitting hidden behind "Map") comes out without a map object. I will try to add the project as a zip file... Bests Thomas
... View more
09-14-2020
09:58 AM
|
0
|
0
|
6110
|
|
POST
|
I want to retrieve a list of map objects from my current ArcGIS Pro 2.6 project. The way I achieve that currently is so: internal void GetMaps()
{
var mapPanes = ProApp.Panes.OfType<IMapPane>();
List<Map> uniqueMaps = new List<Map>();
foreach (var mapPane in mapPanes)
{
if (mapPane.MapView.Map != null)
{
uniqueMaps.Add(mapPane.MapView.Map);
}
}
Maps = uniqueMaps;
} Executing the method in a saved project (aprx) where I have nine map panes returns an IEnumerable<IMapPane> with a count of nine. However, line seven in the snippet above was introduced because the foreach loop was failing on the add-method (line 9) in some cases. Debugging and playing with the project before executing the GetMaps() methode showed that map panes, that would return null for their map property in an as-is-project suddenly return a map if the map was activated before executing the GetMap() method. How can I get rid of this behaviour and/ or is there a possibility to by-pass the issue? Bests Thomas
... View more
09-14-2020
03:53 AM
|
0
|
5
|
6191
|
|
POST
|
After a while not coding Python in ArcGIS I get the feeling I am a bit rusty... In ArcGIS Pro (2.5.1) I created a PytonToolbox and started to add parameters, namely DEWorkspace, GPMap, and DEFolder. While the workspace and map parameters work almost as expected, the folder parameter does not. As an example here how I implemented one of the folder parameters: lyr01 = arcpy.Parameter(
displayName = "LYR directory",
name = "lyrx_aju",
datatype = "DEFolder",
parameterType = "Optional",
direction = "Input",
category = "Updates"
) The result of it is as expected a browse button with associated textbox. When I select a directory in the dialogue through the browse button than the name of the selected directory (not the path!) is shown in the textbox, just to disappear right after. This behaviour makes it pretty hard to make a user understand there is a directory selected... Then there is the part with the enabled property/method of the parameter object. It does not matter the slightest if I add an enabled = False in the code snippet above or not. The control is always enabled. Using the updateParameters function for the same purpose: if parameters[0].value is not None:
parameters[1].enabled = True
parameters[2].enabled = True
else:
parameters[1].enabled = False
parameters[2].enabled = False returns with a hidden parameter 1, but a visible, and enabled parameter 2. As soon as I select a value in parameter 0, parameter 1 is visualised and it is enabled. Last but not least, if I run the tool, and there is nothing in the execute function than the return (it does not matter if there is something more in the execute function), then I am getting the message that the tool failed. The tool fails with error 000820: The parameters need repair. --> The tool parameters have changed since the model was last updated. When a tool that is used in a model is modified, the model needs to be modified to recognize the tool as it exists now. The suggested solution has sure enough the precision of a mass murderer... Some edits will be required on the model. If I understand correctly then model means the pyt file... Problem is, I can do what ever I want to the code in the pyt file, it will not change the outcome of the tool run. Does somebody has a solution for the problem with DEFolder, and the error 000820? Best regards Thomas
... View more
09-11-2020
12:05 AM
|
0
|
0
|
1140
|
|
POST
|
I know it's more than a minimal example! Sorry for that! You find the definition of the textbox in question in line 49 of the pane xaml. backstage tab xaml: Link backstage tab code behind: Link backstage tab view model: Link pane xaml: Link pane code behind: Link pane view model: Link
... View more
11-07-2019
01:18 AM
|
0
|
1
|
3291
|
|
POST
|
Hi Gintautas, that's how I normally define my properties and I tried that, but also this does not reflect on the textbox text property: private string _urlDHM;
public string UrlDHM
{
get => _urlDHM;
set => SetProperty(ref _urlDHM, value, ()=> UrlDHM);
}
protected async override Task InitializeAsync()
{
UrlDHM = AppSettings.Default.urlDHM;
await base.InitializeAsync();
} In fact the breakpoint I set on line 9 is never fired.
... View more
11-07-2019
12:56 AM
|
0
|
3
|
3291
|
|
POST
|
Hi Gintautas, yes, I have my own custom settings file. I think I am running loops here... The backstage tab has its view model and the respective xaml file is setting the data context to its own view model. The same applies to the pane. Both view models are set as internal. What ever I do in the view model of the backstage tab has no effect on the text property. Makes sense so far, since the binding in the pane xaml file is looking into the panes view model... If I define the following in the panes view model then it doesn't have an effect either: public static string UrlDHM;
public static void GetSettings()
{
UrlDHM = Appsettings.Default.urlDHM;
}
protected async override Task InitializeAsync()
{
GetSettings();
await base.InitializeAsync();
}
... View more
11-07-2019
12:32 AM
|
0
|
5
|
3291
|
|
POST
|
I am trying to provide my users with the possibility to adjust values that I by default set in a settings file of my addin through a backstage tab. I designed the UI in the tab to resample the tab design of ArcGIS Pro (link to my question about the UI) and have now a ArcGIS Pro Pane on the right hand where I put some textboxes. When initializing the backstage tab the settings file should be read and the textboxes populated with the respective values. Here I have my first question, since the ArcGIS Pro Pane comes with its own view model... do I have to put the code there or is it absolutely fine to put the code into the code behind file? My other question is about how to get the retrieved values into the textboxes. Currently I have a public property in the view model and I can see the xaml file is aware of the property bound to it, but I have no clue about where to put the code to retrieve the value from the settings file.
... View more
11-06-2019
01:33 AM
|
0
|
8
|
3476
|
|
POST
|
I couldn't find a guide on how to style the backstage area in ArcGIS Pro and the BackStage_PropertyPage project in the community samples contains only a header and a checkbox. What components are used in the xaml to build and style the following UI? My current attempt is: <Grid Margin="20,0">
<StackPanel>
<TextBlock Style="{DynamicResource Esri_TextBlockBackStageTitle}" Text="{Binding TabHeading}" />
<!-- design content for the tab here -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="navItemStepper" Grid.Column="0" Content="Stepper"
MinHeight="52" FontSize="24" VerticalAlignment="Top"
Style="{DynamicResource Esri_ButtonBorderless}" Click="NavItemStepper_Click" />
<Line Style="{StaticResource verticalLineBackstage}" />
<Frame x:Name="faks_main" Grid.Column="2" NavigationUIVisibility="Hidden" Margin="15,15,0,0"/>
</Grid>
</StackPanel>
</Grid>
... View more
11-01-2019
03:24 AM
|
0
|
0
|
1058
|
|
POST
|
The 'esri_mapping_popupToolContextMenu' has a couple of items in it that access the map coordinates from the click event calling the context menu. Since I have my own button/item in the 'esri_mapping_popupToolContextMenu' I would like to access these coordinates to use them in the OnClick method of my button. How can I get these coordinates?
... View more
10-24-2019
04:21 AM
|
0
|
1
|
1320
|
|
POST
|
John, your references certainly helped. However, this requires that there is an object that is selected. Is there a refId to add to the context menu that you get when using the 'explore tool'? Edit: I found it! It's the 'esri_mapping_popupToolContextMenu'
... View more
10-24-2019
01:20 AM
|
1
|
1
|
2291
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-09-2026 01:54 AM | |
| 1 | 10-24-2022 01:23 AM | |
| 1 | 09-15-2021 01:21 AM | |
| 2 | 08-30-2022 04:31 AM | |
| 2 | 04-24-2024 04:23 AM |
| Online Status |
Offline
|
| Date Last Visited |
05-08-2026
05:14 AM
|