YouTube | Facebook | X(Twitter) | RSS

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

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上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『"地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

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