|
POST
|
I think I figured it out! Adding all of the added overlays in a collection seems to work. namespace SAWS_Sewer_Connections
{
class OverlayUtils
{
private static System.IDisposable _overlayObject = null;
private static IList<System.IDisposable> _allOverlays = new List<System.IDisposable>();
public static void RemoveFromMapOverlay(MapView mapView)
{
if (_overlayObject != null)
{
foreach (var overlay in _allOverlays) overlay.Dispose();
_overlayObject.Dispose();
_overlayObject = null;
}
}
public static void UpdateMapOverlay(ArcGIS.Core.Geometry.MapPoint point, MapView mapView)
{
//if (_overlayObject != null)
//{
// _overlayObject.Dispose();
// _overlayObject = null;
// AddToMapOverlay(point, mapView);
//}
//else
//{
// //first time
// AddToMapOverlay(point, mapView);
//}
AddToMapOverlay(point, mapView);
}
public static async void AddToMapOverlay(ArcGIS.Core.Geometry.MapPoint point, MapView mapView)
{
ArcGIS.Core.CIM.CIMPointSymbol symbol = null;
await QueuedTask.Run(() =>
{
// Construct point symbol
symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 5, SimpleMarkerStyle.Square);
});
//Get symbol reference from the symbol
CIMSymbolReference symbolReference = symbol.MakeSymbolReference();
await QueuedTask.Run(() =>
{
_overlayObject = mapView.AddOverlay(point, symbolReference);
_allOverlays.Add(_overlayObject);
});
}
}
} Thanks Uma Harano!!
... View more
06-26-2020
08:22 AM
|
1
|
0
|
2174
|
|
POST
|
Hi Uma Harano, I've pretty much got this working, but the one thing that is causing me problems is the removal of the graphics when I select a new row in my table to add new points. Only the most recently added overlay point gets removed. I'm basically using the same code as from the Geocode sample to do this. Here is my OverlayUtils code: namespace SAWS_Sewer_Connections
{
class OverlayUtils
{
private static System.IDisposable _overlayObject = null;
public static void RemoveFromMapOverlay(MapView mapView)
{
if (_overlayObject != null)
{
_overlayObject.Dispose();
_overlayObject = null;
}
}
public static void UpdateMapOverlay(ArcGIS.Core.Geometry.MapPoint point, MapView mapView)
{
//if (_overlayObject != null)
//{
// _overlayObject.Dispose();
// _overlayObject = null;
// AddToMapOverlay(point, mapView);
//}
//else
//{
// //first time
// AddToMapOverlay(point, mapView);
//}
AddToMapOverlay(point, mapView);
}
public static async void AddToMapOverlay(ArcGIS.Core.Geometry.MapPoint point, MapView mapView)
{
ArcGIS.Core.CIM.CIMPointSymbol symbol = null;
await QueuedTask.Run(() =>
{
// Construct point symbol
symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 5, SimpleMarkerStyle.Square);
});
//Get symbol reference from the symbol
CIMSymbolReference symbolReference = symbol.MakeSymbolReference();
await QueuedTask.Run(() =>
{
_overlayObject = mapView.AddOverlay(point, symbolReference);
});
}
}
} And here is the code I run when the selection in my ListView changes: foreach (var oid in selectedOIDs)
{
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
insp.Load(gsFLayer, oid);
//Get the To and From point of the currently selected feature
var pointCollection = ((ArcGIS.Core.Geometry.Multipart)insp.Shape).Points;
if (currentSurvey.direction == "U")
{
fromPoint = pointCollection[pointCollection.Count - 1];
}
else
{
fromPoint = pointCollection[0];
}
//MessageBox.Show(insp["FACILITYID"].ToString() + " - " + fromPoint.X.ToString() + ", " + fromPoint.Y.ToString());
MapView mapview = MapView.Active;
OverlayUtils.RemoveFromMapOverlay(mapview);
ArcGIS.Core.Geometry.MapPoint connPoint = null;
double theLength = ((ArcGIS.Core.Geometry.Multipart)insp.Shape).Length;
foreach (var currentDetail in lstDetails.Items.OfType<detailItems>())
{
if (currentSurvey.direction == "U")
{
connPoint = ArcGIS.Core.Geometry.GeometryEngine.Instance.QueryPoint((ArcGIS.Core.Geometry.Multipart)insp.Shape, ArcGIS.Core.Geometry.SegmentExtension.NoExtension, theLength - (double)currentDetail.distance, ArcGIS.Core.Geometry.AsRatioOrLength.AsLength);
}
else
{
connPoint = ArcGIS.Core.Geometry.GeometryEngine.Instance.QueryPoint((ArcGIS.Core.Geometry.Multipart)insp.Shape, ArcGIS.Core.Geometry.SegmentExtension.NoExtension, (double)currentDetail.distance, ArcGIS.Core.Geometry.AsRatioOrLength.AsLength);
}
OverlayUtils.UpdateMapOverlay(connPoint, mapview);
}
//OverlayUtils.UpdateMapOverlay(fromPoint, mapview);
} I guess they are all individual objecsts, but is there a way to get RemoveFromMapOverlay to remove everything, not just the last one created??
... View more
06-26-2020
07:32 AM
|
0
|
1
|
2174
|
|
POST
|
Is there a simple way to use GeometryEngine.Instance.QueryPoint to get a point a specified distance from the end of the line? It seems to default to the start of the line?? Or do I just need to add some math logic to my code??
... View more
06-26-2020
07:02 AM
|
0
|
2
|
1049
|
|
POST
|
Ah, thanks Rich for giving my brain a kick and knocking some sense into me! Turns out i was looking at a block of code from an ArcObjects project I worked on where I knew I was doing a similar thing. I had converted that project to ArcGIS Pro, but was just looking at the wrong project. I am good now!! This seems to work for anyone interested. QueuedTask.Run(() =>
{
var gsSelection = gsFLayer.GetSelection();
IReadOnlyList<long> selectedOIDs = gsSelection.GetObjectIDs();
foreach (var oid in selectedOIDs)
{
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
insp.Load(gsFLayer, oid);
//Get the To and From point of the currently selected feature
var pointCollection = ((ArcGIS.Core.Geometry.Multipart)insp.Shape).Points;
ArcGIS.Core.Geometry.MapPoint fromPoint = pointCollection[0];
ArcGIS.Core.Geometry.MapPoint toPoint = pointCollection[pointCollection.Count - 1];
MessageBox.Show(insp["FACILITYID"].ToString());
}
});
... View more
06-25-2020
12:44 PM
|
0
|
1
|
6918
|
|
POST
|
I have no idea what why i can't figure this out, but after hours of trying i am finally having to get some help. All I want to do is get the selected line feature from a FeatureLayer object so I can get the starting point (fromPoint). Here is my current version of code: QueuedTask.Run(() =>
{
var gsSelection = gsFLayer.GetSelection();
using (ArcGIS.Core.Data.RowCursor rCursor = gsSelection.Search())
{
while (rCursor.MoveNext())
{
Feature gsFeature = rCursor.Current as Feature;
IPolyline6 gsPolyline = gsFeature as IPolyline6;
IPoint fromPoint = gsPolyline.FromPoint;
}
}
}); Earlier in my code I use this to get the layer, which appears to be working. I can get to the attributes of the selected feature without any issues. gsFLayer = map.GetLayersAsFlattenedList().OfType<ArcGIS.Desktop.Mapping.FeatureLayer>().Where(l => l.Name.IndexOf("GISWRKS1.WORKS.GravitySewer", StringComparison.CurrentCultureIgnoreCase) >= 0).FirstOrDefault(); I get a NullReference exception at IPoint fromPoint = gsPolyline.FromPoint; Any help is appreciated. Thanks!
... View more
06-25-2020
11:09 AM
|
1
|
3
|
6988
|
|
POST
|
Hi, What I'm trying to figure out is a way to add graphics to the map, at specific distances along a selected line. See my example below. The user selects a line segment, then a database is queried that shows all of the sanitary sewer connection lines along that line. What I want to do is to put a point on the screen at each specified distance (starting at the start or end of the line) to show where each connection is. I've never messed with graphics in ArcGIS Pro SDK before, so any guidance is appreciated. Thanks!
... View more
06-24-2020
10:40 AM
|
0
|
4
|
2249
|
|
POST
|
Hi Sean, Yes, I had onDemand = false. What I was doing was recreating a tool that already existed. So it had a new GUID and version #, yet everything else was the same to facilitate easily copy/pasting code from one to the other. In the end what fixed it was deleting the original .esriAddIn file and replacing it with the new one. My setup for testing was to load the original tool through a network path, and then load the new tool through the local AddIns folder as I was testing it with VisualStudio. Both tools were appearing in the toolbar, but only the original was working properly. Not sure why I had to delete the original one to finally get things working, but it is all working now. Thanks,
... View more
05-19-2020
07:15 AM
|
0
|
0
|
2010
|
|
POST
|
I've created many custom tools in ArcMap, with most of them using the fuctionality where they are grayed out until the user starts an edit session. The code I have always used is like this: public class ToFromTool_AddIn : ESRI.ArcGIS.Desktop.AddIns.Button
{
private ESRI.ArcGIS.esriSystem.UID editorUID = new ESRI.ArcGIS.esriSystem.UIDClass();
private ESRI.ArcGIS.Editor.IEditor3 m_editor;
protected override void OnUpdate()
{
Enabled = m_editor.EditState != esriEditState.esriStateNotEditing;
}
}
It's been a while since I've created a new ArcMap tool, but for some reason the new tool I have created will not activate when I start an edit session. There must be something I have missed, but I cannot figure it out. Any ideas of what I need to check??
... View more
05-14-2020
12:38 PM
|
0
|
2
|
2080
|
|
POST
|
Hi Scott, Basically what I am trying to do is figure out a way to share templates. I'm only using .lyrx files because that seems to be the only mechanism for doing that right now. In my group of 7 or 8 people, we all edit data, and all need to use the same tools to edit the same data (a versioned SDE). As these 'Group Templates' are a bit of a pain to setup, it makes sense to try and share them amongst each other instead of having to create them from scratch each time. For example, the one 'Group Template' highlighted below actually creates four different features. So it's super convenient to use, but a bit of a pain to setup. So from your response above, it sounds like creating a 'Group Layer File' would solve this. I did just finish testing and it seems to work. It's a different workflow for us. Currently (in ArcMap) we just drag and drop layers from SDE into a map, hit our 'Symbolize Layer' button (pulling from Layer files), and everything works. Everyone uses the 'old school' editing (ie. NOT template editing) in ArcMap, so I'm trying to bridge the gap to make the transition to ArcGIS Pro as easy as possible. And using group templates will allow me to not have to rewrite the code I have working in ArcMap to work in ArcGIS Pro. I want to use as much 'out of the box' functionality as possible and stop maintaining code. Now with the 'renaming' of the template issue I am seeing, this is how it is happening for me using an example of a group template for creating a Mainline/Manhole feature: 1. Create a 'Template' for the Mainline, using default value for all attributes. 2. Create a 'New Group Template' by right-clicking the template from #1. Edit the 'Builders' to also include a Manhole feature at the end of the line. 3. Save, close and reopen ArcGIS Pro. Both templates are still there. 4. Rename the template from step #1. 5. Save, close and reopen ArcGIS Pro. Template #2 is now missing. Is this supposed to happen? I would think that when I do step #2, I am creating a copy of the first template which is totally independent from the one created in step #1.
... View more
04-20-2020
11:09 AM
|
0
|
1
|
1000
|
|
POST
|
Ok.....so I did some more testing and I need to revise what I said. If I 'drag and drop' the .lyrx file into ArcGIS Pro, then 'Yes', I do see the templates listed. The Group Templates are blank regardless of whether the other related features are or are not in the map at the time of drag and drop. Do you know if this issue is something being looked at? What I originally did was use my .NET code for reading a .lyrx file and updating the symbology. So I guess what I need to figure out now is how to extract the template information out of the .lyrx file. Bringing the symbology in seems to be working using something like this: featureLayer?.SetRenderer(((CIMFeatureLayer)cimLyrDoc.LayerDefinitions[0]).Renderer as CIMUniqueValueRenderer); But I will now have to extract template information too. Any advice?? Thanks!
... View more
04-20-2020
07:54 AM
|
0
|
3
|
6368
|
|
POST
|
Hi Scott, So I am back into working with 'Group Templates' and was hoping you could answer a few questions. Here are the templates I am working with in my 'Water Service' feature class: 1. Originally I had more 3 templates here. After I renamed Fireline, ICI Water Service, and Res. Water Service (to include the ###mm diameter) and closed/opened ArcGIS Pro, I lost the 3 other templates that were associated to each of the mentioned ones. Should that have happened? 2. If I create a Layer File of Water Service, with templates, the templates are not showing up when I add the layer file to a new project. Group Template, or not group template, it doesn't seem to matter. All I see are the 'default' templates, not the ones that the layer had when I created the .lyrx file. Do you know if this is something being addressed since we originally discussed this in 2018?? After adding the layer file to a new map, this is what I get (even with/without the other layers required for the group templates). Thanks!
... View more
04-20-2020
07:26 AM
|
0
|
4
|
6368
|
|
POST
|
Hi Uma Harano, When I change .Intersects to .Crosses I get some better results. The points that are not intersecting are fine, but now the points that ARE intersecting are not getting any value transferred over. From reading the description on that link you sent me, it sounds like .Crosses will not work in my case. I am using a point/line combination... "Crosses - Returns a feature if the intersection of the interiors of the two shapes is not empty and has a lower dimension that the maximum dimension of the two shapes. Two lines that share an endpoint do not cross. Valid for polyline/polyline, polyline/Area, multipoint/Area, and multipoint/polyline shape type combinations." Do you have any other suggestions?? Is there another reason why the .Intersects will not work when the point/line are very close, but not intersecting??
... View more
03-20-2020
06:08 AM
|
0
|
1
|
1362
|
|
POST
|
Hi, In the Legend for my layout, the spacing in it visually appears to be off, yet in the settings everything is set to a common 5 pixel spacing. The vertical spacing does not appear to match what's in the settings for the Legend. Any advice on how to get things lined up properly would be great. There are 4 layers going on here: - "Frequent Jetting" and "Gravity Sewer" are the same layer - "Easement" is one layer - "Maintenance Hole" and "Inspection MH" are the same layer - "Cleanout" in one layer
... View more
03-12-2020
06:17 AM
|
0
|
0
|
501
|
|
POST
|
Hi, How close do two object have to be in order for a SpatialFilter Intersect considers them to be intersecting? I'm doing some testing at a very small scale and getting some 'not expected' results. In the screenshot below, I am running the following code to find the intersecting Watermain ID to place onto the Watermain Break point. So basically I pass the point of the selected Watermain Break and the Watermain Layer to this procedure (GetIntersectingFeature), and then update the Watermain Break: public string GetIntersectingFeature(MapPoint point, FeatureLayer intersectLayer, string fieldName)
{
try
{
//ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(point.X.ToString() + " : " + point.Y.ToString());
//Create a Spatial Query using the supplied point, layer and fieldname
SpatialQueryFilter spatialFilter = new SpatialQueryFilter();
spatialFilter.FilterGeometry = point;
spatialFilter.SpatialRelationship = SpatialRelationship.Intersects;
spatialFilter.SubFields = fieldName;
//Gets the intersecting feature
string fieldValue = null;
RowCursor featureCursor = intersectLayer.Search(spatialFilter);
Feature feature;
//Gets the value using the fieldName
while (featureCursor.MoveNext())
{
using (feature = (Feature)featureCursor.Current)
{
int fieldPosition = feature.FindField(fieldName);
if (feature[fieldPosition] != null)
fieldValue = feature[fieldPosition].ToString();
else
fieldValue = null;
}
}
return fieldValue;
}
catch (Exception ex)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("An error occured while finding the intersecting feature." + "\n" + "\n" + ex.ToString(), "GetIntersecingFeature", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
return null;
}
} From the screenshot below, all of the selected points have a value returned. I really only should be getting a value returned for the Watermain Breaks that are exactly intersecting the Watermain. Is there a setting I am missing in either ArcGIS Pro, or in my code to tighten up the tolerance of what is considered 'intersecting'?? Thanks,
... View more
03-11-2020
07:54 AM
|
0
|
3
|
1491
|
|
POST
|
Hi, Not totally sure what the error you are getting means, but I know for the 2.5 SDK that you install it though Tools - Extensions, not the NuGet manager. Maybe try installing from here: Turn off "Automatically Update extension", so your SDK and installed version of ArcGIS Pro don't get out of sync. And make sure to reference .NET Framework 4.8 for all your custom tools.
... View more
03-06-2020
10:25 AM
|
0
|
0
|
1260
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-29-2026 07:40 AM | |
| 1 | 10-17-2023 07:40 AM | |
| 1 | 04-14-2026 08:54 AM | |
| 2 | 08-18-2023 08:57 AM | |
| 1 | 04-13-2018 10:07 AM |
| Online Status |
Offline
|
| Date Last Visited |
05-29-2026
09:43 AM
|