|
POST
|
I think the problem is that you use the Active MapView to query for the feature class. You need to get the map frame in your layout, then use its map to find your feature layer like this - needless to say you need to know the name of the map frame you want to zoom - note you need to zoom to selection instead of the layer which is the 2nd parameter of the SetCamera call: //Perform on the worker thread
await QueuedTask.Run(() =>
{
//Reference MapFrame
MapFrame mf = layout.FindElement("Map Frame") as MapFrame;
//Reference map and layer
Map m = mf.Map;
FeatureLayer lyr = m.FindLayers("GreatLakes").First() as FeatureLayer;
//Set the map frame extent to selected features in the layer (2nd parameter)
mf.SetCamera(lyr, true);
}); in case you don't know how to get the layout use this (note that i used the Pro SDK help documentation specifically the ProSnippets for layouts to find these code snippets @ ProSnippets Layouts · Esri/arcgis-pro-sdk Wiki · GitHub 😞 // Reference a layoutitem in a project by name
LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MyLayout"));
if (layoutItem != null)
{
//Perform on the worker thread
QueuedTask.Run(() =>
{
// Reference and load the layout associated with the layout item
Layout layout = layoutItem.GetLayout();
if (layout != null)
{
....
}
}
}
... View more
09-15-2020
01:31 PM
|
0
|
0
|
1338
|
|
POST
|
Sorry about the delay, Brian, but I just now got around to revisit your issue. Let me first summarize what i think the workflow and the resulting problems are: A MapTool is used to sketch a line. The sketched line geometry is used to create two points: a 'Connection' point which is the 'from' point of the line (first point) and a 'Plug' point, which is the 'to' point of the line (last point). The points are computed as shown here: MapPoint connectionPoint = ((Multipart)geometry).Points[0]; MapPoint plugPoint = ((Multipart)geometry).Points[((Multipart)geometry).PointCount - 1]; A new fitting feature is created using the plugPoint (let's call this one fitting) using the plugPoint's geometry by calling: plugPoint.Clone(). The fitting's attributes are also driven by the 'Connection' point, which should be connected to a water man. The first problem is that the coordinates of plugPoint are changed as a result of calling 'Clone' and hence your fitting's point location is not coincident with plugPoint. Is that still the case as stated in your original question above? The second problem is that the fitting turns into a service point type because the Connection point is not connected to the water main? I also wanted to know what projection your data is using. Is it the same projection as is used by your sample map? NAD_1983_UTM_Zone_17N? I wrote a test program to duplicate the Clone problem and i was not able to duplicate the problem. For the second issue i would first look at the snapping configuration in your MapTool. Make sure the tool is configured to snap to the correct layer(s) ... i think we have discussed this in another thread: https://community.esri.com/thread/258729-help-with-finding-intersecting-layer
... View more
09-15-2020
11:29 AM
|
0
|
0
|
3855
|
|
POST
|
I use this functionality often and never have seen an issue, so I assume this issue is specific to your layer definition and/or data. In the attribute table you can select a feature and then use the 'zoom to' function to see where that takes you on the map, maybe there's a projection problem. If you add the layer through the UI in Pro it works fine? Is it failing only when you add it through the SDK?
... View more
09-15-2020
06:38 AM
|
0
|
0
|
1312
|
|
POST
|
Hi Brian, I don't think it's possible to get different coordinates for points stored as part of a line feature or a point feature as long as both feature class have the same spatial reference and domain settings, regardless weather you clone the point or not. Can you send me a map package (you can attach the map package using the advanced editor option) that contains your map with your relevant layers (needless to say i don't need any data)? With the map package i get all relevant map and feature class spatial references and domains. I will try to duplicate the issue you are seeing. I made a test add-in and can't duplicate the issue. The two coordinates you display on your image, where exactly are those values coming from? Can you give me a code snippet?
... View more
09-11-2020
11:51 AM
|
0
|
2
|
3855
|
|
POST
|
Clone does not change the point geometry, however, when the point is stored in a feature class the xy resolution could come into play.
... View more
09-11-2020
09:39 AM
|
0
|
4
|
3855
|
|
POST
|
There is a ProGuide for styling: ProGuide Style Guide · Esri/arcgis-pro-sdk Wiki · GitHub and there are references for brushes and colors: Esri Brushes Esri Colors And here is some sample code that might be of help: arcgis-pro-sdk-community-samples/Framework/Styling-with-ArcGIS-Pro at master · Esri/arcgis-pro-sdk-community-samples · G…
... View more
09-10-2020
07:53 AM
|
0
|
2
|
2214
|
|
POST
|
Regarding option 2: the location string will get overwritten each time the operator changes it from the backstage options window. The content of the user.config is self explained, simply make the change from your options menu and check the tag that's being used to store your change.
... View more
09-08-2020
09:13 AM
|
1
|
0
|
2413
|
|
POST
|
Option 1: you have to look at the parameters here: Package Project (Data Management)—ArcGIS Pro | Documentation and call the geoprocessing task as demonstrated here: arcgis-pro-sdk-community-samples/Geoprocessing/GeoprocessingExecuteAsync at master · Esri/arcgis-pro-sdk-community-sampl… Option 2: no, the SDK doesn't support read/write to backstage properties. I guess you can try to write the property into the user.config settings file (%appdata%\Esri\ArcGISPro.exe_StrongName....\2.6.0.0\user.config) where these properties are stored. New projects will not be removed since Pro saves them automatically. 'New' projects are only deleted if the operator deletes the project folder.
... View more
09-04-2020
02:22 PM
|
0
|
2
|
2413
|
|
POST
|
The easy way is to use the LinearUnit.Wkt property to get the 'well known text' of the linear unit and store the wkt string instead of the LinearUnit type. At the point of retrieval you can then use CreateLinearUnit with the wkt text as an input parameter.
... View more
09-03-2020
01:52 PM
|
1
|
0
|
2091
|
|
POST
|
I added the dockpane with multiple TableControls sample here: https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/TableControlsDockpane
... View more
09-02-2020
04:33 PM
|
0
|
1
|
1614
|
|
POST
|
Hi Marvis, There is a table control that you can use for your dockpane (https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-TableControl), however, the TableControl is read-only. I will add a community sample soon with an attribute table dockpane that contains multiple TableControls, but it's still a read-only implementation. So currently your 'esri_editing_table_openTablePaneButton' approach is probably the best way to implement your workflow needs.
... View more
09-02-2020
10:51 AM
|
0
|
2
|
1614
|
|
POST
|
When i moved the last line: newMap.SetSpatialReference(spatialReference) to a line before the map is assigned to the mapframe it worked: protected override async void OnClick()
{
try
{
await QueuedTask.Run(() =>
{
string mapName = $"Map-Copy";
//Get the map
MapProjectItem mapProjectItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name == "Map");
Map originalMap = mapProjectItem.GetMap();
// Make a copy of the map
Map newMap = MapFactory.Instance.CopyMap(originalMap);
newMap.SetName(mapName);
SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(6455);
// Change the spatial reference of the map
newMap.SetSpatialReference(spatialReference);
// Get the map frame in the layout
LayoutProjectItem layoutProjectItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name == "Layout");
Layout layout = layoutProjectItem.GetLayout();
MapFrame frame = layout.Elements.FirstOrDefault(e => e.Name == "Map Frame") as MapFrame;
//Set the map frame's map to the new copy
frame.SetMap(newMap);
});
}
catch (Exception ex)
{
MessageBox.Show($@"Exception: {ex}");
}
}
... View more
09-01-2020
04:07 PM
|
0
|
2
|
1320
|
|
POST
|
You are correct the TableControl, which provides the means to find the select row and the associated object id, is not accessible. We will have to enhance the API in the future to close that gap. However, for the time being there is a workaround by searching through the visual elements in order to find the corresponding TableControl. I attached my sample code, which is using your main components. To get the sample to work you have to select any layer to be shown in the "Attribute table" dockpane in the TOC of the Contents dockpane: Then click the "Show Attribute Table" button on the Add-in tab: Now you should be able to select a row on any table and zoom to the shape's envelope. Just to highlight how to find the TableControl visual element: // get the Visual Tree root element from your user control's ViewModel:
public class AttributeTableViewModel : DockPane
{
...
// this should be the visual tree root of our user control
var visualTreeRoot = this.Content;
}
// using the visual tree root from above we can now traverse the visual tree to find our 'TableControl'
var tableControl = VisualTreeRoot.GetChildOfType<TableControl>();
if (tableControl != null)
{
// use the table control
}
// and the GetChildOfType<> extension to find a child element of given type in a visual tree
public static T GetChildOfType<T>(this DependencyObject depObj)
where T : DependencyObject
{
if (depObj == null) return null;
for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(depObj); i++)
{
var child = System.Windows.Media.VisualTreeHelper.GetChild(depObj, i);
System.Diagnostics.Debug.WriteLine(child.GetType());
var result = (child as T) ?? GetChildOfType<T>(child);
if (result != null) return result;
}
return null;
}
... View more
09-01-2020
10:53 AM
|
0
|
1
|
1607
|
|
POST
|
Hi Sai, I duplicated the problem with version 2.4 and 2.4.2. It looks like the bit depth is 32 instead of 24. I then tried the same Add-in with 2.5 and it worked as expected. So it appears that the problem has been fixed with 2.5.
... View more
08-31-2020
09:23 AM
|
0
|
1
|
2880
|
|
POST
|
I think your problem is caused by the fact that you are calling the snippet during the project saving event. I implemented a simple button and experienced no issues with the path. However, if you look closely at what 'save as' does, you will notice that it only saves the .aprx file in the 'save as' path, the local database and other project artifacts stay behind in the local path. There are some workarounds for this: 1) You can save a 'project package' each time the user is trying to 'save' a project and then set the project's dirty flag to false. This will actually copy everything to the shared unc location. However, once you open the project package you have to perform the same 'save as' workflow each time since otherwise the 'save' operation (on an opened project package) saves now and aprx on the local drive. 2) You can change the project 'default' locations in the ArcGIS options: 3) Similar to 2) above you can provide a 'customized create new projects button' which makes use of the following project class method: CreateAsync (CreateProjectSettings createProjectSettings) createProjectSettings allows you to specify the default locations (in your case the unc path).
... View more
08-31-2020
08:22 AM
|
0
|
4
|
2413
|
| 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 |
05-21-2026
01:59 PM
|