|
POST
|
Ah....your a genius Wolfgang!! I had a layer in the TOC called GISWRKS1.WORKS.Watermain_Breaks that was causing the problem. So, is there a way to look for a layer name with an EXACT match??
... View more
08-21-2020
12:06 PM
|
0
|
2
|
3299
|
|
POST
|
Yes, the tool has it turned on too. public HydrantTool()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Line;
SketchOutputMode = SketchOutputMode.Map;
UseSnapping = true;
} Also, this is how I am getting the watermain layer, but I don't see any issues here either: FeatureLayer waterMainLayer;
waterMainLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name.IndexOf("GISWRKS1.WORKS.WaterMain", StringComparison.CurrentCultureIgnoreCase) >= 0).FirstOrDefault();
... View more
08-21-2020
10:56 AM
|
0
|
4
|
3299
|
|
POST
|
Hi Wolfgang Kaiser, Yes, within OnToolActivateAsync I have the tool turn it on, just in case the user doesn't. And in my testing it is definitely turned on. //turn on snapping in case the user does not have it set in their map
Snapping.IsEnabled = true;
Snapping.SetSnapMode(SnapMode.Edge, true);
Snapping.SetSnapMode(SnapMode.End, true);
... View more
08-21-2020
10:43 AM
|
0
|
6
|
3299
|
|
POST
|
Hi Wolfgang Kaiser. Thanks for creatign that. After running your tool, it is working with all of my layers. Did you do something different in yours?? I still don't understand why the exact same code is returning false when I run it. I renamed the layer causing problems to TestLines, and it worked with yours.
... View more
08-21-2020
10:09 AM
|
0
|
1
|
3299
|
|
POST
|
Hi. I'm creating a series of MapTools to sketch a line on the map that will represent a new feature. A criteria of the sketch is that the first node of the sketch must intersect a line feature. So for example, to create a hydrant lateral the first click must intersect a watermain....the second click will represent the hydrant valve and the last the hydrant. I have created a routine for checking for the intersection of the first click to a given layer, but I am getting mixed results. With certain layers it works (ie. my sewer layer for my sewer connection tool), but other layers (ie. my watermain layer for my hydrant tool). Here is the code: public static bool IntersectsLayer(MapPoint point, FeatureLayer layer)
{
try
{
SpatialQueryFilter spatialFilter = new SpatialQueryFilter();
spatialFilter.FilterGeometry = point;
spatialFilter.SpatialRelationship = SpatialRelationship.Intersects;
RowCursor theCursor = layer.Search(spatialFilter);
Feature feature;
while (theCursor.MoveNext())
{
using (feature = (Feature)theCursor.Current)
{
return true;
}
}
}
catch (Exception ex)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(ex.ToString());
}
return false;
} And here is the code that calls it: protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
//use the sketch geometry to create the connectionPoint, valve and hydrant
var pointCollection = ((Multipart)geometry).Points;
MapPoint connectionPoint = pointCollection[0];
MapPoint hydrantPoint = pointCollection[pointCollection.Count - 1];
MapPoint valvePoint = pointCollection[1];
//start creating the features
QueuedTask.Run(() =>
{
if (Global.IntersectsLayer(connectionPoint, waterMainLayer) == false)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(connectionPoint.X.ToString() + ", " + connectionPoint.Y.ToString(), "Error");
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("The starting point must intersect the WaterMain or Water Service layer.", "Error");
return;
}
....... Can anyone see anything wrong in the code? For some reason it always returns false when using the watermain layer. I have snapping turned on, and it always works when using my similarly coded sewer connection tool. Any ideas are appreciated.
... View more
08-21-2020
08:10 AM
|
0
|
12
|
4329
|
|
POST
|
Hi, Have you tried looking at ArcGIS Pro 2.6 API Reference Guide for the MapSelectionChangedEvent. You could add some logic so when the selection changes to populate your listbox, etc.
... View more
08-18-2020
12:00 PM
|
1
|
0
|
2887
|
|
POST
|
Hi, So in my application the user selects multiple sewer lines to start. I then have a dockpanel that gets regfreshed to show the ID of the users selection in a listbox. Now what I want is that when the user selects the ID of one of the lines in the dockpanel, that the selection in the map changes to show only that line as selected. I am doing all of my coding for this in the _SelectionChanged event of the list, but running into a "The calling thread cannot access this object because a different thread owns it." error. What can I do to get around this?? After clicking on one of the ID's in the listbox below is when the error comes up. Thanks,
... View more
08-14-2020
08:45 AM
|
0
|
2
|
1851
|
|
POST
|
Hi Wolfgang Kaiser. Thanks for that tip. That is a very handy tool I hadn't seen before!! Your tool is working in both maps. I then tried my tool again in the imported on, and it still wasn't working at the same time yours was. So i made another Map in my project, and it did work in that. So still totally confusing. I ended up linking the imported map with this new map just so I was working with the same data in each. And then 'poof'....magically everything started working in the imported map. Not sure if it's a coincidence or not, but I'll keep an eye on it. Strange goings-ons. 🙂
... View more
08-14-2020
08:13 AM
|
0
|
1
|
1743
|
|
POST
|
Hi Wolfgang Kaiser. What version of ArcGIS Pro did you build that project on? All of the references come up as 'missing'. I am on 2.6.0
... View more
08-14-2020
06:29 AM
|
0
|
3
|
1743
|
|
POST
|
Hi Uma Harano, I eventually figured this out. Back in ArcObjects, things just seemed to work differently. What I am trying to do is set the ROTATION of an 'end of line' point feature so that things look proper when mapping. After lots of messing about, I finally figured out that if I just applied a * -1 to my formula and then everything worked. var lineBuilder = new LineBuilder(fromPoint, toPoint); var line = lineBuilder.ToSegment(); double Rad2Degrees = 180 / Math.PI; var degrees = (line.Angle * Rad2Degrees) * -1; return degrees; Thanks for getting back to me.
... View more
08-13-2020
07:08 AM
|
0
|
0
|
2122
|
|
POST
|
Hi, I've created a tool that draws graphics (Overlay) onto the screen to help identify sewer connections. It's all working fine....most of the time. See below for an example. What I am finding is that in some .aprx files the graphics draw fine, but in others they do not. I think it may be a case of when the .aprx is created by importing an old .mxd document into ArcGIS Pro. Does anyone know if that might be the cause?? Or should I be looking something else?? With a 'pure' .aprx file, no problems (ie. the red arrows get drawn): With an imported .mxd to .aprx file, problems (ie. no graphics get drawn):
... View more
08-13-2020
07:03 AM
|
0
|
5
|
1787
|
|
POST
|
Hi Sean Jones. You are correct. The same mouse click is producing two different points, but they both have the same Spatial Reference. How can that be??
... View more
08-11-2020
06:11 AM
|
0
|
0
|
2824
|
|
POST
|
Hi Sean Jones. I've modified to use ScreenToMap, but no difference. Calling my IntersectsLayer code from OnToolMouseDown just doesn't seem to work. But calling it from OnSketchComplete does. Very strange considering both methods should be using the same information.
... View more
08-10-2020
11:41 AM
|
0
|
2
|
2824
|
|
POST
|
Thanks Cody, What I ended up doing was using our existing ortho, and just using the georeferencing tools to pull everthing into place. At the time, using control points was not an option, but going forward I will look into adding that to our process. Thanks!
... View more
08-10-2020
11:02 AM
|
1
|
1
|
4811
|
| 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
|