Is there any way to get the Z-Coordinate when snapping?

597
3
Jump to solution
09-17-2013 08:28 AM
SuiHuang
Occasional Contributor II
Hi Everybody:

    I am writing some code to do snapping. When I snap a new point (with X and Y only) to an existing point feature (with XYZ coordinates). I will get the XY of the feature that it is snapped to, but not Z. Following is my current code. Is there anyway to identify the Z coordinate of the feature? For example, find the feature that is snapped to first, and then get Z?

    Thank you!

// X, Y are the mouse coordinates, get the point on the map with Lat-Long but without Z coordinate IPoint mapPoint; mapPoint = QueryMapPoint((m_application.Document as IMxDocument).ActivatedView.ScreenDisplay, X, Y);  // snap ISnappingResult snapResult = m_Snapper.FullSnap(mapPoint); if (snapResult != null) {     IPoint SnappedMousePoint = snapResult.Location;   // only get the XY, but Z=NaN }
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Z snapping is only supported through the classic snapping environment. You can enable classic snapping on the UI through the editor options dialog or through the IEditProperties4.ClassicSnapping Property.

The help topic Working with the editor snap environment has a section on how to snap in x,y,z. Basically you enable zsnapping on feature snap agents, set the z snapping environment (ISnapEnvironment3) then snap a ZAware point with ISnapEnvironment.SnapPoint. We are working to make this easier in the future.

This pattern is used in the old 9.3 sample Z management properties. The sample has been rewritten for 10.1 as Z Management Toolbar.

View solution in original post

0 Kudos
3 Replies
DuncanHornby
MVP Notable Contributor
I have to admit I have never utilised any snapping objects in ArcObjects so maybe an interface does exist? If not, are you saying the geometry you are snapping to has a Z value? If so, this is one way to do it:

Cast your geometry into IPointCollection, cycle over this until you have the vertex you snapped to then query that vertex for a Z value.

The method I am suggesting assumes you are snapping to vertices.
0 Kudos
JeffMatson
Occasional Contributor III
I think if you make the point ZAware it should pick up the Z values automatically

Dim zAware As IZAware
Set zAware = pPoint
zAware.zAware = True



Hi Everybody:

    I am writing some code to do snapping. When I snap a new point (with X and Y only) to an existing point feature (with XYZ coordinates). I will get the XY of the feature that it is snapped to, but not Z. Following is my current code. Is there anyway to identify the Z coordinate of the feature? For example, find the feature that is snapped to first, and then get Z?

    Thank you!

// X, Y are the mouse coordinates, get the point on the map with Lat-Long but without Z coordinate
IPoint mapPoint;
mapPoint = QueryMapPoint((m_application.Document as IMxDocument).ActivatedView.ScreenDisplay, X, Y);

// snap
ISnappingResult snapResult = m_Snapper.FullSnap(mapPoint);
if (snapResult != null)
{
    IPoint SnappedMousePoint = snapResult.Location;   // only get the XY, but Z=NaN
}
0 Kudos
by Anonymous User
Not applicable
Z snapping is only supported through the classic snapping environment. You can enable classic snapping on the UI through the editor options dialog or through the IEditProperties4.ClassicSnapping Property.

The help topic Working with the editor snap environment has a section on how to snap in x,y,z. Basically you enable zsnapping on feature snap agents, set the z snapping environment (ISnapEnvironment3) then snap a ZAware point with ISnapEnvironment.SnapPoint. We are working to make this easier in the future.

This pattern is used in the old 9.3 sample Z management properties. The sample has been rewritten for 10.1 as Z Management Toolbar.
0 Kudos