Sub SmoothPolygons2() Dim pMxDoc As IMxDocument Dim pMap As IMap Dim ET As New ETGW_Core Dim pFeatureLayer As IFeatureLayer Dim pInFeatureClass As IFeatureClass Dim pOutFeatureClass As IFeatureClass Dim pLabelFeatureClass As IFeatureClass Dim bDone As Boolean On Error GoTo EH Set pMxDoc = ThisDocument Set pMap = pMxDoc.FocusMap Set pFeatureLayer = pMxDoc.SelectedLayer If pFeatureLayer Is Nothing Then MsgBox "No selected layer" Exit Sub End If Set pInFeatureClass = pFeatureLayer.FeatureClass Set pLabelFeatureClass = ET.PolygonToPoint(pInFeatureClass, "c:\00\labels.shp", "Label", False) If pLabelFeatureClass Is Nothing Then MsgBox "Error in step 0" Exit Sub End If Set pOutFeatureClass = ET.PolygonToPolyline(pInFeatureClass, "c:\00\polylines.shp") If pOutFeatureClass Is Nothing Then MsgBox "Error in step 1" Exit Sub End If Set pOutFeatureClass = ET.CleanPolyline(pOutFeatureClass, "c:\00\polylines_clean.shp", 0.0001) If pOutFeatureClass Is Nothing Then MsgBox "Error in step 2" Exit Sub End If Set pOutFeatureClass = ET.DensifyPolylines(pOutFeatureClass, "c:\00\polylines_densified.shp", 0.02, 0.02) If pOutFeatureClass Is Nothing Then MsgBox "Error in step 3" Exit Sub End If Set pOutFeatureClass = ET.SmoothPolylines(pOutFeatureClass, "c:\00\polylines_smooth.shp", "bSpline", 5, 3) If pOutFeatureClass Is Nothing Then MsgBox "Error in step 4" Exit Sub End If Set pOutFeatureClass = ET.GeneralizePolylines(pOutFeatureClass, "c:\00\polylines_generalized.shp", 0.0002) If pOutFeatureClass Is Nothing Then MsgBox "Error in step 5" Exit Sub End If Set pOutFeatureClass = ET.BuildPolygons(pOutFeatureClass, "c:\00\polygons.shp", False, 0.0001) If pOutFeatureClass Is Nothing Then MsgBox "Error in step 6" Exit Sub End If Set pOutFeatureClass = ET.Spatial_Join(pOutFeatureClass, pLabelFeatureClass, _ "c:\00\polygons_final.shp", "Nearest", True, 0) If pOutFeatureClass Is Nothing Then MsgBox "Error in step 7" Exit Sub End If bDone = ET.DeleteShapefile("c:\00\labels.shp") bDone = ET.DeleteShapefile("c:\00\polylines.shp") bDone = ET.DeleteShapefile("c:\00\polylines_clean.shp") bDone = ET.DeleteShapefile("c:\00\polylines_densified.shp") bDone = ET.DeleteShapefile("c:\00\polylines_smooth.shp") bDone = ET.DeleteShapefile("c:\00\polylines_generalized.shp") bDone = ET.DeleteShapefile("c:\00\polygons.shp") Set pFeatureLayer = New FeatureLayer Set pFeatureLayer.FeatureClass = pOutFeatureClass pFeatureLayer.Name = pOutFeatureClass.AliasName pMap.AddLayer pFeatureLayer Set pMxDoc = Nothing Set pMap = Nothing Set pFeatureLayer = Nothing Set pInFeatureClass = Nothing Set pOutFeatureClass = Nothing Set pLabelFeatureClass = Nothing Exit Sub EH: MsgBox Err.Description End Sub