pDoc = m_pApp.Document pMap = pDoc.FocusMap ''get the selection from the layer Dim pFCursor As IFeatureCursor Dim pSelectionSet As ISelectionSet Dim pFSelection As IFeatureSelection pFSelection = pMap.Layer(0) Dim pPoly As IPolygon Dim pArea As IArea Dim pPoint As IPoint Dim lat As Decimal 'not sure exactly which number format you'd want to use Dim lon As Decimal Dim pFeat As IFeature = pFCursor.NextFeature Do Until pFeat Is Nothing pPoly = pFeat.ShapeCopy pArea = pPoly pPoint = pArea.Centroid lat = pPoint.X lon = pPoint.Y pFeat = pFCursor.NextFeature Loop
James, I am trying to create an Add-In following this link:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000001ms000000
But I cannot find ArcGIS node under project type. What do I need to do in order to get that in Visual Studio?
I apologise for these questions as I am a bit of a beginner in Arc.
I will be adding this to ArcMap and hopefully, once it is up and running, my colleagues will be using it too.
Thanks.
I *think* this is because you do not have the ArcGIS .NET SDK ("Developer Kit") installed. Can someone else confirm this?
I think I need ArcGIS Visual Studio Integration Framework!
Is there any other way I can acheive this? i.e. build a custom tool based on a model?
So, I am not certain if the VS IDE Framework is what you need. I do believe that the reason why no ArcGIS Project templates show up is because you simply do not have the ArcGIS .NET SDK installed.
Sub CreateCentroid() pDoc = m_pApp.Document pMap = pDoc.FocusMap Dim pFCursor As IFeatureCursor Dim pSelectionSet As ISelectionSet Dim pFSelection As IFeatureSelection pFSelection = pMap.Layer(0) Dim pPoly As IPolygon Dim pArea As IArea Dim pPoint As IPoint Dim lat As Long Dim lon As Long Dim pFeat As IFeature IFeature = pFCursor.NextFeature Do Until pFeat Is Nothing pPoly = pFeat.ShapeCopy pArea = pPoly pPoint = pArea.Centroid lat = pPoint.X lon = pPoint.Y pFeat = pFCursor.NextFeature Loop End Sub
pFSelection = pMap.Layer(0)
Dim pDoc As IMxDocument Dim pMap As IMap
pDoc = m_pApp.Document
Dim pDoc As IMxDocument pDoc = Application.Document