ArcEngine 9.3 .Net Framework

252
2
04-18-2012 06:57 AM
New Contributor
Hi !

I recover a point in pGeometry (type : Igeometry) , and I would like to draw it in the screen, but I have some troubles with the following code :

            Dim pGraphicsContainer As IGraphicsContainer
            pGraphicsContainer = Form1.AxMapControl1.Map.BasicGraphicsLayer
            Dim ppoint As IPoint
            ppoint = New Point
            ppoint = pGeometry  !!!
            pGraphicsContainer.AddElement(pElement, 0)
            Form1.AxMapControl1.Refresh()


The cast is impossible between ppoint and pgeometry !!!
Reply
0 Kudos
2 Replies
Occasional Contributor III
Hi !

I recover a point in pGeometry (type : Igeometry) , and I would like to draw it in the screen, but I have some troubles with the following code :

            Dim pGraphicsContainer As IGraphicsContainer
            pGraphicsContainer = Form1.AxMapControl1.Map.BasicGraphicsLayer
            Dim ppoint As IPoint
            ppoint = New Point
            ppoint = pGeometry  !!!
            pGraphicsContainer.AddElement(pElement, 0)
            Form1.AxMapControl1.Refresh()

The cast is impossible between ppoint and pgeometry !!!


Not exactly sure what you are trying to achieve (surely there is more code than this?) but if you want to construct a Point then:

        // in C#
        IPoint point = new PointClass();
        point.PutCoords( YourX, YourY );


this will do it.
Reply
0 Kudos
Regular Contributor II
All points are geometries, not all geometries are points.
It is possible that the igeometry passed in is of a different type like line, polygon etc.
if you write something like this, a failed cast will return null.
ppoint = trycast( pGeometry, IPoint)
If ppoint isnot nothing then
  'do something
else
  'geometry is not point
end if

You may also consider using IGeometry.GeometryType
Reply
0 Kudos