Select to view content in your preferred language

ArcEngine 9.3 .Net Framework

552
2
04-18-2012 06:57 AM
IdrissEL_Achabi
Emerging 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 !!!
0 Kudos
2 Replies
GeorgeFaraj
Frequent 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 !!!


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.
0 Kudos
AlexanderGray
Honored Contributor
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
0 Kudos