Sub SplitPolygonLayer() Dim pMxDoc As IMxDocument Dim pMap As IMap Dim pFeatureLayer As IFeatureLayer Dim pInFeatureClass As IFeatureClass Dim pOutFeatureClass As IFeatureClass Dim pTempFeatureClass As IFeatureClass Dim bDone As Boolean Set pMxDoc = ThisDocument Set pMap = pMxDoc.FocusMap Set pFeatureLayer = pMxDoc.SelectedLayer Set pInFeatureClass = pFeatureLayer.FeatureClass '======================================================================= Dim ET As New ETGW_Core Dim sOutFileName As String Dim dFuzzyTol As Double Dim pSplitLayer As IFeatureLayer Dim pSplitFeatureClass As IFeatureClass 'an exaple on how to get a feature layer by name ' Get the polyline layer to be used for splitting Set pSplitLayer = ET.GetLayer("split_layer") If pSplitLayer Is Nothing Then Exit Sub End If Set pSplitFeatureClass = pSplitLayer.FeatureClass sOutFileName = "c:\00\split2.shp" 'Convert the polygons to polylines Set pTempFeatureClass = ET.PolygonToPolyline(pInFeatureClass, "c:\00\pg2pl.shp") If pTempFeatureClass Is Nothing Then MsgBox "Error in step 0" Exit Sub End If 'Merge the polylines with the Split polyline layer Set pTempFeatureClass = ET.merge(pTempFeatureClass, pSplitFeatureClass, "c:\00\merged.shp") If pTempFeatureClass Is Nothing Then MsgBox "Error in step 1" Exit Sub End If 'Build polygons from merged dataset 'Note that the bClean must be set to TRUE ==> the merged polylines should be 'cleand before using them to build polygons dFuzzyTol = 0.002 Set pOutFeatureClass = ET.BuildPolygons(pTempFeatureClass, "c:\00\pg_temp.shp", True, dFuzzyTol) If pOutFeatureClass Is Nothing Then MsgBox "Error in step 2" Exit Sub End If 'In order to get the attributes from the original polygons we need to '1. Get the label points of the newly created polygons Set pTempFeatureClass = ET.PolygonToPoint(pOutFeatureClass, "c:\00\lab1.shp", _ "Label", False) If pTempFeatureClass Is Nothing Then MsgBox "Error in step 3" Exit Sub End If '2. Attach the attributes from the original polygons to the label points Set pTempFeatureClass = ET.Spatial_Join(pTempFeatureClass, pInFeatureClass, _ "c:\00\lab2.shp", "Within", False, 0) If pTempFeatureClass Is Nothing Then MsgBox "Error in step 4" Exit Sub End If '3. Attach the attributes from the label points to the split polygons Set pOutFeatureClass = ET.Spatial_Join(pOutFeatureClass, pTempFeatureClass, _ sOutFileName, "Nearest", False, 0) If pOutFeatureClass Is Nothing Then MsgBox "Error in step 5" Exit Sub End If ' Delete the intermediate datasets bDone = ET.DeleteShapefile("c:\00\pg2pl.shp") bDone = ET.DeleteShapefile("c:\00\merged.shp") bDone = ET.DeleteShapefile("c:\00\pg_temp.shp") bDone = ET.DeleteShapefile("c:\00\lab1.shp") bDone = ET.DeleteShapefile("c:\00\lab2.shp") '======================================================================== 'Add the split polygons as a layer in the Map Set pFeatureLayer = New FeatureLayer Set pFeatureLayer.FeatureClass = pOutFeatureClass pFeatureLayer.Name = pOutFeatureClass.AliasName pMap.AddLayer pFeatureLayer End Sub