リプレゼンテーションを適用してフィーチャ レイヤーをマップに追加

投稿日:2016/9/1 (木) 更新日:

'リプレゼンテーションを適用してフィーチャ レイヤをマップに追加
 
'Add a Feature Class with Representations Programmatically
'http://help.arcgis.com/en/sdk/10.0/vba_desktop/conceptualhelp/index.html#//00010000003q000000
Public Sub AddRepresentationClass()
  On Error GoTo errorhandler
       
  Dim pWorkspaceFactory As IWorkspaceFactory
  Dim pFeatureWorkspace As IFeatureWorkspace
  Dim pFeatureLayer As IFeatureLayer
  Dim pMxDocument As IMxDocument
  Dim pMap As IMap
  Dim pRC As IRepresentationClass
  Dim pGeoFL As IGeoFeatureLayer
  Dim pRepRend As IRepresentationRenderer
  Dim pRendPropPage As IRendererPropertyPage
   
  'Create a new AccessWorkspaceFactory object and open a personal geodatabase
  Set pWorkspaceFactory = New FileGDBWorkspaceFactory
  Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile("C:\Programs\ArcGIS\ArcTutor\Representations\Exercise_5\Representations_5.gdb", 0) 'ジオデータベース ワークスペース
   
  'Get the representation workspace extension from workspace
  Dim pExtManager As IWorkspaceExtensionManager
  Dim pRepWE As IRepresentationWorkspaceExtension
  Dim pUID As IUID
  Set pExtManager = pFeatureWorkspace
  Set pUID = New UID
  pUID.Value = "{FD05270A-8E0B-4823-9DEE-F149347C32B6}"
  Set pRepWE = pExtManager.FindExtension(pUID)
  Set pRC = pRepWE.OpenRepresentationClass("RoadP_Rep") 'リプレゼンテーション クラス名(フィーチャクラス プロパティ → リプレゼンテーション タブから確認)
   
  'Create a new FeatureLayer and assign the feature class to it
  Set pFeatureLayer = New FeatureLayer
  Set pFeatureLayer.FeatureClass = pRC.FeatureClass
  pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName
  'Add the FeatureLayer to the focus map
  Set pMxDocument = Application.Document
  Set pMap = pMxDocument.FocusMap
  pMap.AddLayer pFeatureLayer
   
  'Use representation renderer to draw the features
  Set pRepRend = New RepresentationRenderer
  Set pRepRend.RepresentationClass = pRC
  Set pGeoFL = pFeatureLayer
  Set pGeoFL.Renderer = pRepRend
  Set pRendPropPage = New RepresentationRulesPropertyPage
  pGeoFL.RendererPropertyPageClassID = pRendPropPage.ClassID
  'Refresh map drawing and update table of contents (TOC)
  pMxDocument.ActiveView.Refresh
  pMxDocument.UpdateContents
  Exit Sub
errorhandler:
    MsgBox Err.Description, vbInformation, "AddRepresentationClass"
End Sub

関連記事

  • この記事を書いた人

羽田 康祐

伊達と酔狂でエクストリーム スポーツに挑む GIS エンジニア。 GIS、IT、趣味に関して日々の出来事で学んだ記憶を記録するためにブログを書いています。同じ問題に出会った方の参考になっていただければ幸いです。GIS を使った自己紹介はこちら

-プログラミング, ArcGIS
-,

Copyright© WINGFIELD since1981 , 2019 All Rights Reserved.