여러개의 레이어를 한번에 Define 할수 있는 VBA 입니다.
FeatureClass를 대상으로 하지만 IGeoDataset 인터페이스를 사용함으로 코드를 조금수정하면 Raster도 같은 방법으로 할수 있습니다.
Public Sub DefineProjection()
Dim sPrjPath As String
sPrjPath = "C:\XXXXXXX.prj"
Dim pSR As ISpatialReference
Dim pSRS As ISpatialReferenceFactory2
Set pSRS = New SpatialReferenceEnvironment
Set pSR = pSRS.CreateESRISpatialReferenceFromPRJFile(sPrjPath)
Dim pDoc As IMxDocument
Dim pMap As IMap
Set pDoc = ThisDocument
Set pMap = pDoc.FocusMap
Dim pLayers As IEnumLayer
Set pLayers = pMap.Layers
Dim pLyr As IFeatureLayer
Set pLyr = pLayers.Next
Dim pFClass As IFeatureClass
Dim pGeoDS As IGeoDataset
Dim pGeoDsSchemaEdit As IGeoDatasetSchemaEdit
Do While Not pLyr Is Nothing
Set pFClass = pLyr.FeatureClass
Set pGeoDS = pFClass
Set pGeoDsSchemaEdit = pGeoDS
Call pGeoDsSchemaEdit.AlterSpatialReference(pSR)
Set pLyr = pLayers.Next
Loop
MsgBox "Success~!!"
End Sub
댓글 없음:
댓글 쓰기