Public Sub polygony()
Dim pLayer As IFeatureLayer
Dim pFC As IFeatureClass
Dim pointCol As IPointCollection
Dim ctverec As IPolygon
Dim bod As IPoint
Set pLayer = getLayer("kraje")
Set pFC = pLayer.FeatureClass
Set pointCol = New Polygon
Set bod = New Point
bod.X = -800000
bod.Y = -1100000
pointCol.AddPoint bod
Set bod = New Point
bod.X = -400000
bod.Y = -1100000
pointCol.AddPoint bod
Set bod = New Point
bod.X = -400000
bod.Y = -900000
pointCol.AddPoint bod
Set bod = New Point
bod.X = -800000
bod.Y = -900000
pointCol.AddPoint bod
Set ctverec = pointCol
ctverec.Close
Dim feat As IFeature
Set feat = pFC.CreateFeature
Set feat.shape = ctverec
feat.Store
End Sub
Private Function getLayer(name As String) As IFeatureLayer
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Set pMxDoc = Application.Document
Set pMap = pMxDoc.FocusMap
Dim pLayers As IEnumLayer
Dim pLayer As IFeatureLayer
Set pLayers = pMap.Layers
Set pLayer = pLayers.Next
While Not pLayer Is Nothing
If pLayer.name = name Then
Set getLayer = pLayer
Exit Function
End If
Set pLayer = pLayers.Next
Wend
If pLayer Is Nothing Then
MsgBox "vrstva nebyla v mape nalezena"
Set getLayer = Nothing
End If
Exit Function
End Function