Estoy actualizando mis addins de 10.0 a 10.1 y mi código está fallando en el método IPolygon2.QueryExteriorRingsEx.
Entiendo que hay algo extraño en este método porque Ayuda al desarrollador dice que no funciona en C# .Net (Ver observaciones: "No funciona en .NET. Use Polygon4.get_InteriorRingBag en su lugar"). En las observaciones también dice que este método sólo acepta un array de tipo IRing para exteriorRings. Usar un array de IRing2 no funcionará. Estoy usando iRing.
Todo funcionaba muy bien en la versión 10.0, pero ahora el método se bloquea si intento consultar más que un solo anillo exterior. (La consulta de un polígono con un anillo exterior pasa)
¿Puede alguien confirmar este comportamiento antes de que intente reescribir este procedimiento utilizando el método Polygon4.get_InteriorRingBag en su lugar?
Procedimiento siguiente - la línea del problema está dentro del bucle do while
Public Sub PolygonsToPolylines(ByVal sourceFeatureLayer As ESRI.ArcGIS.Carto.IFeatureLayer, ByVal destFeatureLayer As ESRI.ArcGIS.Carto.IFeatureLayer)
On Error GoTo trap
Dim MxApplication As ESRI.ArcGIS.ArcMapUI.IMxApplication = TryCast(My.ArcMap.Application, ESRI.ArcGIS.ArcMapUI.IMxApplication)
Dim pEditor As ESRI.ArcGIS.Editor.IEditor2
Dim pEditLayers As ESRI.ArcGIS.Editor.IEditLayers
Dim pActiveView As ESRI.ArcGIS.Carto.IActiveView
Dim pEnumFeature As ESRI.ArcGIS.Geodatabase.IEnumFeature
Dim pFeature As ESRI.ArcGIS.Geodatabase.IFeature
Dim pPolygon As ESRI.ArcGIS.Geometry.IPolygon2
Dim pTempPolyline As ESRI.ArcGIS.Geometry.ITopologicalOperator
Dim pNewFeature As ESRI.ArcGIS.Geodatabase.IFeature
Dim pPolygon2 As ESRI.ArcGIS.Geometry.IPolygon2
Dim pPolyline As ESRI.ArcGIS.Geometry.IPolyline
Dim pPolylinePointColl As ESRI.ArcGIS.Geometry.IPointCollection
Dim pRings() As ESRI.ArcGIS.Geometry.IRing
Dim pRing As ESRI.ArcGIS.Geometry.IRing
Dim pRings2() As ESRI.ArcGIS.Geometry.IRing
Dim pRing2 As ESRI.ArcGIS.Geometry.IRing
'new
Dim pFeatureSelection As ESRI.ArcGIS.Carto.IFeatureSelection
Dim pSelectionSet As ESRI.ArcGIS.Geodatabase.ISelectionSet
Dim pFeatureCursor As ESRI.ArcGIS.Geodatabase.IFeatureCursor = Nothing
Dim r As Long, i2 As Long, r2 As Long, c As Long, c2 As Long
Dim d As Long 'progress dialog counter
Dim source3D As Boolean, dest3D As Boolean
Has_3D_value(sourceFeatureLayer.FeatureClass, source3D) 'determine whether source features class is 3D
Has_3D_value(destFeatureLayer.FeatureClass, dest3D) 'determine whether destination features class is 3D
'Get a handle to the Editor extension
pEditor = GetEditorFromArcMap(MxApplication)
If pEditor Is Nothing Then Exit Sub
pEditLayers = pEditor 'QI
pActiveView = pEditor.Map
If pEditor.EditState = ESRI.ArcGIS.Editor.esriEditState.esriStateNotEditing Then
MsgBox("You must be editing to use this feature!", MsgBoxStyle.Information)
Exit Sub
End If
'QUERY Layer selection to get cursor'''''''''''''''''''''''''''''''''''''''''''''''
pFeatureSelection = sourceFeatureLayer
pSelectionSet = pFeatureSelection.SelectionSet
d = pSelectionSet.Count
If d < 1 Then
MsgBox("You must select at least 1 feature!") : Exit Sub
End If
'retreive selection into a cursor
pSelectionSet.Search(Nothing, False, pFeatureCursor)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Set up Progress Bar''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Create a CancelTracker
'Dim trackCancel As ESRI.ArcGIS.esriSystem.ITrackCancel = New ESRI.ArcGIS.Display.CancelTrackerClass '10.0
Dim trackCancel As ESRI.ArcGIS.esriSystem.ITrackCancel = New ESRI.ArcGIS.Display.CancelTracker '10.1 update
Dim progressDialogFactory As ESRI.ArcGIS.Framework.IProgressDialogFactory = New ESRI.ArcGIS.Framework.ProgressDialogFactoryClass
'Set the properties of the Step Progressor
Dim int32_hWnd As System.Int32 = My.ArcMap.Application.hWnd
Dim stepProgressor As ESRI.ArcGIS.esriSystem.IStepProgressor = progressDialogFactory.Create(trackCancel, int32_hWnd)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Set the properties of the Step Progressor
stepProgressor.MinRange = 0
stepProgressor.MaxRange = d
stepProgressor.StepValue = 1
stepProgressor.Message = "Copying..."
'Create the ProgressDialog. This automatically displays the dialog
Dim progressDialog2 As ESRI.ArcGIS.Framework.IProgressDialog2 = CType(stepProgressor, ESRI.ArcGIS.Framework.IProgressDialog2) ' Explict Cast
' Set the properties of the ProgressDialog
progressDialog2.CancelEnabled = True
progressDialog2.Description = "Copy Features"
progressDialog2.Title = "Copying..."
progressDialog2.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriDownloadFile
' Step. Do your big process here.
Dim boolean_Continue As System.Boolean
boolean_Continue = True
Dim i As System.Int32
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Start an edit operation
pEditor.StartOperation()
pFeature = pFeatureCursor.NextFeature
Do While Not pFeature Is Nothing
'Progress Bar''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim statusBar As ESRI.ArcGIS.esriSystem.IStatusBar = TryCast(My.ArcMap.Application.StatusBar, ESRI.ArcGIS.esriSystem.IStatusBar)
statusBar.Message(0) = i.ToString
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If pFeature.Shape.GeometryType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon Then
c = c + 1
pPolygon2 = pFeature.ShapeCopy
SimplifyGeometry(pPolygon2)
r = pPolygon2.ExteriorRingCount
If r > 0 Then
r = r - 1
ReDim pRings(r)
pPolygon2.QueryExteriorRingsEx(pPolygon2.ExteriorRingCount, pRings(0))
For i = 0 To r
pRing = pRings(i)
r2 = pPolygon2.InteriorRingCount(pRing)
If r2 > 0 Then
r2 = r2 - 1
ReDim pRings2(r2)
pPolygon2.QueryInteriorRingsEx(pRing, pPolygon2.InteriorRingCount(pRing), pRings2(0))
For i2 = 0 To r2
pRing2 = pRings2(i2)
pPolylinePointColl = New ESRI.ArcGIS.Geometry.Polyline
pPolylinePointColl.AddPointCollection(pRing2)
pPolyline = pPolylinePointColl 'QI
SimplifyGeometry(pPolyline)
SimplifyGeometry(pPolyline)
pNewFeature = destFeatureLayer.FeatureClass.CreateFeature
pNewFeature.Shape = pPolyline
CopyFieldValues(pFeature, pNewFeature) 'copy matching field values
pNewFeature.Store()
c2 = c2 + 1
Next
End If
pPolylinePointColl = New ESRI.ArcGIS.Geometry.Polyline
pPolylinePointColl.AddPointCollection(pRing)
pPolyline = pPolylinePointColl 'QI
SimplifyGeometry(pPolyline)
pNewFeature = destFeatureLayer.FeatureClass.CreateFeature
If (dest3D = True And source3D = False) Or (dest3D = True And source3D = True) Then
SetZAware(pPolyline) 'make geometry zAware
'FUTURE UPDATE = COPY or ASSIGN 3D Values to all geometry points
End If
If dest3D = False And source3D = True Then
RemoveZAware(pPolyline) 'remove zAware from geometry
End If
pNewFeature.Shape = pPolyline
CopyFieldValues(pFeature, pNewFeature) 'copy matching field values
pNewFeature.Store()
c2 = c2 + 1
'Check if the cancel button was pressed. If so, stop process
boolean_Continue = trackCancel.Continue
If Not boolean_Continue Then
Exit For
End If
Next
End If
End If
pFeature = pFeatureCursor.NextFeature
Loop
'Done
trackCancel = Nothing
stepProgressor = Nothing
progressDialog2.HideDialog()
progressDialog2 = Nothing
MsgBox("Succesfully created " & c2 & " lines from " & c & " selected polygons.")
'Complete the edit operation
pEditor.StopOperation("Copy Polygons to Polylines")
'Flag the area of the new feature for refreshing
pActiveView.Refresh()
Exit Sub
trap:
MsgBox(Err.Description)
pEditor.AbortOperation()
CancelProgressBar:
'Progress cleanup
progressDialog2.HideDialog()
trackCancel = Nothing
stepProgressor = Nothing
progressDialog2 = Nothing
End Sub
0 votos
El enlace va a la ayuda de la 9.1. La ayuda de la 10.1 (no he comprobado las versiones anteriores) sí incluye esa observación. No estoy seguro de que este enlace funcione, pero... resources.arcgis.com/es/help/arcobjects-net/componenthelp/