POST
|
I use VS Code to debug arcpy on Linux. It can be finicky and I sometimes get the "Xvfb: failed initializing arcpy. Check if environment was activated correctly." error when importing arcpy. The way I use VS Code to debug and run scripts is basically this: 1) I create Python unit tests to step into the arcpy script. I either run proper unit test or just step into and run main() if I want to run the entire script. 2) In VS Code I open an integrated bash terminal and copy and paste the following lines of bash code into it #!/bin/bash export PATH="$PATH:/home/arcgis/anaconda3/bin" export ARCGISHOME=/opt/esri/arcgis/server source activate arcpy3 3) Then in VS Code I make sure the Python interpreter from my arcpy3 conda environment is selected as the Python interpreter. 4) I open the Python unit test file and in VS Code Debug I run the "Python: Current File (Integrated Terminal)" debug configuration to step into a breakpoint.
... View more
11-08-2023
08:54 AM
|
1
|
0
|
426
|
POST
|
I'm having the exact same problem described in the original post at ArcGIS Pro 2.9.5 right now. Any updates with this issue? It's very wonky behavior and seems like a bug. I call GetDefinition() the first time it return the object. Subsequent calls return null. If I call GetDefinition() in another part of the code afterward in another method it returns the object again. Activating the default tool with await async first doesn't fix the issue. This behavior only occurs with specific ArcGIS Server feature layers but I can't see any difference with these particular layers versus other layers where this is not an issue. CIMEditingTemplate iceLineTemplateDef = template.GetDefinition();
... View more
11-08-2022
06:28 PM
|
0
|
0
|
429
|
POST
|
As far as I can tell, you cannot use the Pro SDKs ItemFactory Create method with an ArcGIS Server URL (correct me if I'm wrong). But if you create the service with ArcGIS Pro 2.2+ and AGS 10.6.1+ you can use the URL I posted above to retrieve the metadata as HTML using the ArcGIS Server REST API in a Pro AddIn. I created a helper function to retrieve the HTML metadata and then wrote the string to an HTML file: public async Task<string> GetMetadata(string baseUrl, string format, string output)
{
var values = new Dictionary<string, string>
{
{ "format" , format },
{ "output" , output }
};
var url = baseUrl + "/metadata";
var content = new FormUrlEncodedContent(values);
var response = await _httpClient.PostAsync(url, content);
var responseString = await response.Content.ReadAsStringAsync();
return responseString;
} var metadata = await httpHelper.GetMetadata(baseUrl, "iso19139", "html");
if (File.Exists(metadataFile.FullName))
{
File.Delete(metadataFile.FullName);
}
using (FileStream fileStream = metadataFile.Create())
{
Byte[] text = new UTF8Encoding(true).GetBytes(metadata);
fileStream.Write(text, 0, text.Length);
} https://developers.arcgis.com/rest/services-reference/enterprise/metadata.htm
... View more
08-22-2022
03:53 PM
|
0
|
0
|
377
|
POST
|
I have an ArcGIS Pro web layer that's sourced to an ArcGIS Server URL (not Portal). How do I use the Pro SDK to export the metadata? I know how to do this with File Geodatabases and SDE connection files: var gdbItem = ItemFactory.Instance.Create("K:\\connection_files\\ice_production.sde\\ice_production.ICE_OWNER.ARCTIC_WEEKLY");
IMetadata gdbMetadataItem = gdbItem as IMetadata;
gdbMetadataItem.SaveMetadataAsHTML(metadataFile.FullName, MDSaveAsHTMLOption.esriArcGISFull); And I know the web URL for the layer as a metadata link: https://server.esri.com/arcgis/rest/services/SIPAS/Arctic/FeatureServer/6/metadata The metadata is a customer requirement for a data export from ArcGIS Pro as part of a larger ArcGIS Pro AddIn. I need to write this out to a file as HTML along with the exported data. I would like to use the ArcGIS Server as a source for the metadata instead of using a file path, but I can't seem to get it working or find examples on how to do it.
... View more
08-19-2022
01:44 PM
|
0
|
1
|
420
|
POST
|
Thanks! <group id="Esri_Selection_Group" caption="Advanced Selection" keytip="Z0" launcherButtonID="esri_mapping_openSelectionOptionsButton">
<toolPalette refID="esri_mapping_selectToolPalette"/>
<tool refID="esri_editing_ShowAttributes" size="middle" />
<tool refID="esri_mapping_clearSelectionButton" size="middle" />
</group>
... View more
06-10-2021
06:31 PM
|
0
|
0
|
2989
|
POST
|
So I have a tab group with my custom selection tools and an "Advanced Selection" group with the default Esri selection tools (which are actually working with a highly customized Pro Window). This combination is acceptable to the customer. One question however with the "Selection Options" button. Is there a way in the DAML where I can get the graphic used in the out-of-the-box button instead of the "Select Options" text on my button? <group id="Esri_Selection_Group" caption="Advanced Selection" keytip="Z0">
<toolPalette refID="esri_mapping_selectToolPalette"/>
<tool refID="esri_editing_ShowAttributes" size="middle" />
<tool refID="esri_mapping_clearSelectionButton" size="middle" />
<button refID="esri_mapping_openSelectionOptionsButton" size="middle" />
</group> <button refID="esri_mapping_openSelectionOptionsButton" size="middle" /> My "Selection Options" button: Out-of-the-Box "Selection Options" button: I don't want to use this group because I don't need "Select By Location" or "Select By Attribute" and cannot change the name of the group (to my knowledge): <group refID="esri_mapping_selectionGroup"></group>
... View more
06-10-2021
03:57 PM
|
0
|
0
|
2996
|
POST
|
Maybe what you are looking for is "esri_mapping_selectToolPalette", "esri_editing_ShowAttributes", and "esri_mapping_clearSelectionButton"? I'm not sure, but this may help someone else at any rate because I came across your post while struggling with this on my project. In your Config.daml add the tools and toolPalette: <modules>
<insertModule id="SIPAS_Module" className="SipasModule" autoLoad="false" caption="SIPAS Module">
<groups>
<group id="SIPAS_Selection_Group" caption="Selection" keytip="Z0">
<toolPalette refID="esri_mapping_selectToolPalette"/>
<tool refID="esri_editing_ShowAttributes" size="middle" />
<tool refID="esri_mapping_clearSelectionButton" size="middle" />
</group>
</groups>
<tabs>
<tab id="SIPAS_Tab1" caption="SIPAS" keytip="Z0">
<group refID="SIPAS_Selection_Group"></group>
</tab>
</tabs>
</insertModule>
</modules> In your View Model subscribe to the "OnMapSelectionChanged" event: MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);
private async void OnMapSelectionChanged(MapSelectionChangedEventArgs args)
{
await QueuedTask.Run(() =>
{
try
{
//Eggs is an ObservableCollection of a custom class
Eggs.Clear();
_selectedEggCount = 0;
ShowCanvas = false;
FeatureLayer layer = _layerHelper.GetIcePolygonLayer();
var selection = layer.GetSelection();
IReadOnlyList<long> selectedOIDs = selection.GetObjectIDs();
if (selectedOIDs.Count == 0)
return;
ArcGIS.Core.Data.QueryFilter queryFilter = new ArcGIS.Core.Data.QueryFilter { ObjectIDs = selectedOIDs };
queryFilter.WhereClause = "POLY_TYPE = 'I' Or POLY_TYPE = 'W'";
using (RowCursor rowCursor = layer.Search(queryFilter))
{
while (rowCursor.MoveNext())
{
using (Row row = rowCursor.Current)
{
EggModel egg = new EggModel(row);
Eggs.Add(egg);
}
}
}
}
catch (Exception ex)
{
_logger.Error("Failed to get egg list: " + ex.Message + ex.StackTrace);
}
});
}
... View more
06-07-2021
07:44 PM
|
0
|
0
|
1082
|
POST
|
I marked this as the solution because it answered my question and it works. Thanks, it was very helpful. However, the implementation is complicated. To keep it more standard, the customer agreed to a combination of the Pro SDK Tool select behavior in combination with the standard Pro Select tool as Wolf mentioned (with programmatically turning off selectable layers in conjunction with the OnMapSelectionChanged(MapSelectionChangedEventArgs args) event). This also satisfies my customers requirements. Thanks again.
... View more
06-03-2021
04:47 PM
|
0
|
0
|
3046
|
POST
|
I reuse tools that I can but I need a customized implementation of select to meet my customers requirements.
... View more
06-02-2021
04:03 PM
|
0
|
0
|
3066
|
POST
|
I need to create a custom polygon select tool in Pro that has the same behavior as the default rectangle select tool in ArcGIS Pro. The default behavior is the if you click once, the polygon will be selected (multiple polygons with Shift key pressed down); if you click and drag, you select by rectangle. (Similar to the old IRubberBand in Arc Objects). I cannot figure out how to emulate this behavior using the Pro SDK. I’ve developed a custom point select tool with the Shift multi select behavior using SketchType = SketchGeometryType.Point;
public bool IsShiftKey()
{
return (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift));
}
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
Key keyboardKey = Key.None;
if(IsShiftKey())
{
keyboardKey = Key.LeftShift;
}
SIPAS.Events.SketchGeometryUpdatedEvent.Publish(new SIPAS.Events.SketchGeometryUpdatedEventArgs(this, geometry, keyboardKey));
return base.OnSketchCompleteAsync(geometry);
}
But this does not let you select by rectangle by dragging. If I use SketchType = SketchGeometryType.Rectangle; I cannot multiselect by click or Shift click. I have to click twice to create a rectangle to select a single polygon (which my customer is highly annoyed by). How can I create a custom select tool that has the same behavior as the default Pro select tool on the Edit tab/ribbon?
... View more
06-02-2021
11:39 AM
|
0
|
7
|
3167
|
BLOG
|
I need to do the same thing: persist Pro Project-level settings for my custom AddIn that are changed dynamically in the AddIn. Using the default database in the Pro Project comes to mind, but is there another way of doing this using the Pro SDK? Saving setting data in the Pro Project for AddIn use so it would persist when they close and re-open the Pro Project?
... View more
05-29-2020
03:10 PM
|
0
|
0
|
1287
|
POST
|
Yes, that works. Thanks! I was missing how to set the "BasedOn" property correctly: BasedOn="{StaticResource {x:Type ComboBox}}" So adding this ComboBoxStyle with the "BasedOn" property above as a static resource and setting all the ComboBox styles to it is giving me the exact behavior and look that I was expecting: <controls:ProWindow.Resources>
<ResourceDictionary>
<Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=DescriptionCheckBox, Path=IsChecked}" Value="True">
<Setter Property="DisplayMemberPath" Value="Description" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=DescriptionCheckBox, Path=IsChecked}" Value="False">
<Setter Property="DisplayMemberPath" Value="ManiceCode" />
</DataTrigger>
</Style.Triggers>
</Style>
<ResourceDictionary.MergedDictionaries>
<extensions:DesignOnlyResourceDictionary Source="pack://application:,,,/ArcGIS.Desktop.Framework;component\Themes\Default.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</controls:ProWindow.Resources>
<ComboBox x:Name="cboCT" Style="{StaticResource ComboBoxStyle}" Width="60" MaxDropDownHeight="540" HorizontalContentAlignment="Center" ItemsSource="{Binding Concentrations}" SelectedValuePath="ManiceCode" SelectedValue="{Binding CT, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
... View more
05-26-2020
06:21 PM
|
1
|
0
|
5022
|
POST
|
I already tried this. It doesn't work for me. Have you tested this with the "Dark Theme" while adding a style section to the combobox? All the comboboxes in Pro use the "Dark Theme" when in "Dark Theme" by default (like the dark ones in the attached picture). Open any out-of-the-box tool in Pro while in "Dark Theme" and look what the comboboxes look like. Doing the dynamic resource brushes from the Esri style guide still just switches everything to "Light Theme" for me after adding the <ComboBox.Style> section. The items in the comboboxes still are using the "Dark Theme" however which makes them unreadable. I'm suspecting because I haven't added a "Style" section to the items. The "Style" section contains a "BasedOn" property to allow inheritance, but you can't use it with dynamic resources and I don't know how to set this. It appears that adding a "Style" section will override any Esri styles.
... View more
05-26-2020
11:33 AM
|
0
|
3
|
5022
|
POST
|
I have an ArcGIS Pro AddIn I’m developing and I’m having an issue with ArcGIS Pro Theme Styles being overwritten (I think). I need to change a property in a ComboBox based on an event trigger. This needs to be done in the WPF control’s “Style” section. However, when I do this it seems to overwrite the ArcGIS Pro Theme Style (see below). Is this expected behavior and is there a way I can avoid this? <ComboBox Width="60" MaxDropDownHeight="540" HorizontalContentAlignment="Center" ItemsSource="{Binding Concentrations}" SelectedValuePath="ManiceCode" SelectedValue="{Binding CT, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> <ComboBox.Style> <Style TargetType="{x:Type ComboBox}"> <Setter Property="DisplayMemberPath" Value="Description" /> </Style> </ComboBox.Style> </ComboBox>
... View more
05-22-2020
12:50 PM
|
0
|
5
|
5233
|
POST
|
No, but thanks. It's not a big deal. I already upgraded everything to VS2019, .NET 4.8, and Pro 2.5 by creating a new module addin from scratch and porting everything over. Everything works fine now. I've had a lot of headaches in the past upgrading complex AddIns in ArcMap (and extensions) when we upgraded ArcMap versions. I was just wondering if anyone else is experiencing similar problems with Pro AddIn upgrades. I'm a programmer so it could have been a lot of issues. I have had multiple versions of Visual Studio installed on my laptop (VS2017 and VS2019 now), multiple versions of .NET Framework and .NET Core, multiple 3rd party .NET libraries, lots of versions of Pro and the Pro SDK, etc. Now that I'm up-to-date, when Pro 2.6 is released, I should see an update for the Pro SDK in Visual Studio at the same time?
... View more
03-26-2020
11:04 AM
|
0
|
1
|
876
|
Title | Kudos | Posted |
---|---|---|
1 | 11-08-2023 08:54 AM | |
1 | 05-26-2020 06:21 PM | |
1 | 10-04-2012 10:42 AM |
Online Status |
Offline
|
Date Last Visited |
03-01-2024
07:35 PM
|