|
POST
|
Hi Andy, Here's a short example of how to create a polygon. // current exent of mapView
var extent = MapView.Active.Extent;
var height = extent.Height;
var width = extent.Width;
var centerPt = extent.Center;
// new xmin, xmax, ymin, ymax values - a subset of the extent
var xmin = centerPt.X - width / 4;
var xmax = centerPt.X + width / 4;
var ymin = centerPt.Y - height / 4;
var ymax = centerPt.Y + height / 4;
// create 4 corners of the new polgyon
var pt1 = MapPointBuilderEx.CreateMapPoint(xmin, ymin, MapView.Active.Map.SpatialReference);
var pt2 = MapPointBuilderEx.CreateMapPoint(xmin, ymax, MapView.Active.Map.SpatialReference);
var pt3 = MapPointBuilderEx.CreateMapPoint(xmax, ymax, MapView.Active.Map.SpatialReference);
var pt4 = MapPointBuilderEx.CreateMapPoint(xmax, ymin, MapView.Active.Map.SpatialReference);
// then create a polygon from the set of points
var listPoints = new List<MapPoint>() { pt1, pt2, pt3, pt4 };
var polygon2 = PolygonBuilderEx.CreatePolygon(listPoints, MapView.Active.Map.SpatialReference); There's also the following documentation that can help you discover more about building geometries. - https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geometry There are a lot of different code snippets here too. - https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geometry Thanks Narelle
... View more
11-15-2022
12:39 AM
|
1
|
0
|
1795
|
|
POST
|
Hi Tom, Please see the information I posted here. https://community.esri.com/t5/arcgis-pro-sdk-questions/integration-and-configuration-of-custom-commands/m-p/1206677#M8659 let me know if there are additional questions. Narelle
... View more
09-04-2022
05:40 PM
|
1
|
0
|
509
|
|
POST
|
Dirk, Each type of customization that is part of the DAML file must be assigned a unique ID. We call this the damlID. So when you define a button in your add-in it has a damlID. In the example below the damlID is "acme_AddFromFileButton" <button id="acme_AddFromFileButton"
className=" AddFromFile"
caption="Add from file"
keytip="AF"
largeImage="Images\AddFromFile32.png"
smallImage="Images\AddFromFile16.pngg">
<tooltip heading="Add from file" image="Images\AddFromFile16.png">
Add spatial data files to the project
<disabledText>Requires an open project with a map</disabledText>
</tooltip>
</button> Similarly defining and registering a component in a category requires that the item have a unique damlID. In this definition the damlID is "esri_mapping_bookmarks". Internally we prefix our damlIds with "esri_(moduleName)" so this example belongs to the mapping module. So your daml entry for the emebeddable control category might look like the following <categories>
<updateCatgeory refID="esri_tasks_embeddableControls">
<insertComponent id="unity_editor_embeddedControlID" className="embeddedControlViewModel">
<content className="embeddedControlView" relatedCommand="unity_editor_CreateAssetsButton" autoRunOnly="true"/>
</insertComponent>
</updateCategory>
</categories> where embeeddedcontrolviewModel and embeddedControlView are the classes from step 2 that I explained above. And "unity_editor_CreateAssetsButton" is the damlID of the button that launches your dockPane defined in step 3. Regards Narelle
... View more
08-31-2022
06:38 PM
|
1
|
0
|
1195
|
|
POST
|
Dirk, You will likely have to restructure some of your code to fully implement the ability of embedding your dockpane into the Tasks pane. The daml category that you found ("esri_tasks_embeddableControls") is the correct category to register your code in order for Tasks to recognize it as a component that can be embedded. But the view/viewModel that the daml entry references via the className attribute should be a class that inherits from ArcGIS.Desktop.Framework.Controls.EmbedableControl. You can create one of these using the Visual Studio template. Internally we typically follow the below steps for this pattern. 1. create an internal control and viewModel pair to hold the UI and code behind. 2. create an EmbeddableControl (a view and viewmodel pair) that hosts and instantiates the control and the control's view model from step1 3. create a DockPane (a view and viewmodel pair) that hosts and instantiate the control and the control's view model from step1. 4. The esri_tasks_embeddableControls daml entry reference the view/viewmodel from step 2. The "relatedCommand" attribute in that same daml entry references the buttonID that launches the dockpane from step 3. As you can see, this is an advanced extension pattern that has a certain amount of complexity involved. I hope this information helps to get you started. Let me know if you have additional questions. Narelle
... View more
08-29-2022
06:54 PM
|
0
|
2
|
1210
|
|
POST
|
Hi David, Sorry for the late reply. I have been looking at your post and code and have a few comments. 1. I'm sure you've read the documentation we have about editing annotation and it's special considerations but am including a link here for reference. (https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Editing-Annotation) 2. The API currently doesn't expose the ability to show the yellow "grabhandle" that you see with the built in Move tool (that identifies the feature being moved). We have identified this as future functionality we would like to add but currently do not have a timeline identified. 3. The MapTool.AddOverlay function that you are using will create a graphic from the geometry and symbol parameters that are passed. This is why you see the line being displayed on the screen. The line is the baseline geometry of the annotation feature - the geometry that the annotation text lies on. To see the annotation text on the overlay, you should use the AddOverlay function that takes a CIMGraphic https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic27604.html. The CIMGraphic passed would the CIMTextGraphic of the annotation feature (found from AnnotationProperties.TextGraphic). 4. Because you're dealing with annotation and text, it is also important to use the second parameter of that AddOverlay method - the referenceScale. This can be retrieved from the AnnotationFeatureClassDefinition. await QueuedTask.Run(() =>
{
var annoFC = _layerAnno.GetFeatureClass() as AnnotationFeatureClass;
var annoFCDef = annoFC.GetDefinition() as AnnotationFeatureClassDefinition;
_annoRefScale = annoFCDef.GetReferenceScale();
var refScaleUnits = annoFCDef.GetReferenceScaleUnits();
}); So the AddOverlay routine would become _graphic = AddOverlay(_trackedTextGraphic, _annoRefScale); 5. Unfortunately there is no MapTool.UpdateOverlay method that supports the moving of text graphics in the manner used in your code. This is a gap in our API that was found as a result of looking at your post and it will be fixed in the next Pro release. Thanks for helping to identify this. 6. In the meantime a work around would be to dispose of the previous graphic and create a new one with the CIMTextGraphic at the moved geometry position. Unfortunately because this is in MouseMove, the performance may not be as smooth as the standard tool. Here's a sample of code that could replace your UpdateOverlay call Geometry movedGeometry = null;
if (_trackedSide == "up" || _trackedSide == "down")
{
movedGeometry = GeometryEngine.Instance.Move(_trackedGeometry, x, 0);
}
else
{
movedGeometry = GeometryEngine.Instance.Move(_trackedGeometry, 0, y);
}
lock (_lock)
{
if (_graphic != null)
_graphic.Dispose();
var newGraphic = _trackedTextGraphic.Clone();
newGraphic.Shape = movedGeometry;
_graphic = AddOverlay(newGraphic, _annoRefScale);
} I hope this provides some clarification and helps you make progress with your tool. Please let me know if you have any questions or comments about the above. Regards Narelle
... View more
08-17-2022
08:31 PM
|
1
|
0
|
967
|
|
POST
|
Hi Roxana, Unfortunately these trace options are not currently available in the public API. I will create an issue to add these in a future release. regards Narelle
... View more
08-03-2022
06:12 PM
|
1
|
1
|
825
|
|
POST
|
Hi Karen, If you have access to the tool code, can you see whether the following works for you as a possible workaround to the tool deactivating?
private bool ignoreToolDeactivation = false;
protected override async Task OnToolActivateAsync(bool active)
{
var map = MapView.Active.Map;
var wkid = map.SpatialReference.Wkid;
// wkid 102038 = world from space
if (wkid != 102038)
{
await QueuedTask.Run(() =>
{
ignoreToolDeactivation = true;
var sr = SpatialReferenceBuilder.CreateSpatialReference(102038);
map.SetSpatialReference(sr);
});
}
else
ignoreToolDeactivation = false;
await base.OnToolActivateAsync(active);
}
protected override Task OnToolDeactivateAsync(bool hasMapViewChanged)
{
if (ignoreToolDeactivation)
{
// dont let the tool deactivate
FrameworkApplication.SetCurrentToolAsync(this.ID);
}
return Task.CompletedTask;
} Thanks Narelle
... View more
07-17-2022
09:08 PM
|
1
|
1
|
1342
|
|
POST
|
Hello, I don't believe we have anything in the public API that will currently support what you are trying to accomplish with regards to highlighted rows. We do have an issue in the backlog to add additional API functionality to the attributes pane so I will add this requirement to that list. We are hoping to address this issue for the next release. Thanks Narelle
... View more
07-13-2022
10:24 PM
|
0
|
1
|
727
|
|
POST
|
Hi Karen, I have taken a look at this, and can duplicate the behavior that you're seeing. Namely that modifying some map properties - either via some of the API calls or by modifying the CIMMap properties directly - can cause the sketch to be cancelled. In your scenario because you haven't yet started a sketch this will cause the tool to become deactivated. Unfortunately, I don't have a workaround at this time. But can I ask you to explain your workflow as to why you are changing the map's spatial reference in the tool activation. If I understand your workflow, perhaps I can make a suggestion which will avoid the problem. thanks Narelle
... View more
07-13-2022
10:21 PM
|
0
|
3
|
1359
|
|
POST
|
Hi Berndt, Yes, sorry. The code I gave you was 3.0 code. OpenMapPaneAsync was OpenMapPane in previous versions of the SDK (we added the Async suffix at 3.0 for naming consistencies). Rather than the name of the map / mapView / pane it is better to be using the CIM path of the map. This is guaranteed to be unique within the project and is exposed as Map.Uri. It is also the MapProjectItem.Path and also IMapPane.ContentID. so the code above would be as follows if you were starting with a map name. private void ActivateOrOpenMapPane(string mapName)
{
var mapProjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(mpi => mpi.Name == mapName);
if (mapProjItem != null)
{
// is it already open? - check the open panes
var mapPane = ProApp.Panes.OfType<IMapPane>().FirstOrDefault(mPane => (mPane as Pane).ContentID == mapProjItem.Path);
if (mapPane != null)
{
var pane = mapPane as Pane;
pane.Activate();
}
else
{
// open a new mapPane
mapProjItem.OpenMapPaneAsync();
// OR use the following
// it does the same thing as MapProjectItem.OpenMapPaneAsync
//QueuedTask.Run(() =>
//{
// var map = mapProjItem.GetMap();
// ProApp.Panes.CreateMapPaneAsync(map);
//});
}
}
else
{
// mapName is not in the project.
}
} Let me know if this still doesn't execute as you expect for your workflow. Narelle
... View more
06-26-2022
11:20 PM
|
0
|
0
|
1629
|
|
POST
|
Hi David, I'd recommend taking a look at this section of the map exploration ProConcepts with regards to handling mouse down in a MapTool https://github.com/ArcGIS/arcgis-pro-sdk/wiki/ProConcepts-Map-Exploration#mouse-and-keyboard-events and this sample which offers as example (In particular look at the way the BasicMapTool uses the OnToolMouseDown and HandleMouseDownAsync methods) https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/6078006a3943364f2a7931b19d1eb03c8a99e1cf/Map-Exploration/BasicMapTool There are similar options for MouseUp and MouseMove on the MapTool. You could incorporate these methods into your solution. One option would be to note when a left mouse down occurs (ie set a variable - mouseDown = true), trap the mouse move (and perform some action when mousedown == true), and finally note when the mouse up occurs (and clear the mouseDown variable). You could execute the editOperation in the MouseUp if enough distance has been travelled by the mouse. I hope this gives you some ideas. Narelle
... View more
06-26-2022
09:05 PM
|
1
|
1
|
1057
|
|
POST
|
Hi Berndt, Take a look at the following snippet. As I understand, it will achieve what you're asking for. That is, if there is an open pane for the map it will activate it. If there isn't a map pane, it will create / open one. private void ActivateOrOpenMapPane(string mapName)
{
var mapProjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(mp => mp.Name == mapName);
if (mapProjItem != null)
{
// is it already open? - check the open panes
var mapPane = ProApp.Panes.OfType<IMapPane>().FirstOrDefault(pane => pane.Caption == mapName);
if (mapPane != null)
{
var pane = mapPane as Pane;
pane.Activate();
}
else
{
// open a new mapPane
mapProjItem.OpenMapPaneAsync();
// OR use the following
// it does the same thing as MapProjectItem.OpenMapPaneAsync
//QueuedTask.Run(() =>
//{
// var map = mapProjItem.GetMap();
// ProApp.Panes.CreateMapPaneAsync(map);
//});
}
}
else
{
// mapName is not in the project.
}
} I apologize for the snippet "Get the Unique List of Maps From the Map Panes" crashing. At early releases of ArcGIS Pro the MapPane objects were always fully populated (that is the MapView and the Map could be accessed), however over the releases loading optimizations have taken place and now the Map on the MapView is only accessible after it has been the active MapView. This is the issue that you're seeing that is causing the crash. I will ensure that the code is removed. Please let me know if the snippet provided doesn't help. Narelle.
... View more
06-26-2022
06:28 PM
|
0
|
3
|
1639
|
|
POST
|
Hello, Currently the API only provides the ability to geocode addresses and return locations. It is not presently possible to reverse geocode locations to obtain address results. We will add this as an enhancement to the API in a future release. Narelle
... View more
06-16-2022
04:37 PM
|
0
|
0
|
540
|
|
POST
|
Hi Brian, In the case where you are calling EditOperation.Modify with an inspector object that has not actually changed any attributes, then internal optimizations will see this as an empty operation and won't actually add it to the list of work to be done when EditOperation.Execute occurs. This is why the tracking fields are not updated on your feature. Tracking fields are only updated when a change (attribute or spatial) is made to the record. In addition if there is no work to be done (ie EditOperation.IsEmpty returns true), then yes, an EditOperation.Execute will return false. In your situation, you can check the EditOperation.IsEmpty property and only call EditOperation.Execute if there is work to be done. Narelle
... View more
06-01-2022
07:09 PM
|
1
|
0
|
1864
|
|
POST
|
Hi , We don't have anything to use the prj file directly, but I believe you should be able to use the following code as the prj file contains text in the wkt format. I have wrapped the CreateSpatialReference call in a try/catch in case of error which would need to be handled. try
{
string path = @"c:\60571.prj";
var sText = System.IO.File.ReadAllText(path);
SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(sText);
}
catch (Exception e)
{
} Regards Narelle
... View more
05-29-2022
08:06 PM
|
0
|
1
|
1057
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 07-27-2025 06:04 PM | |
| 1 | 03-24-2025 06:53 PM | |
| 1 | 08-08-2024 09:44 PM | |
| 1 | 07-18-2024 04:46 PM | |
| 1 | 06-04-2024 07:18 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-02-2025
02:15 PM
|