lic211
路人甲
路人甲
  • 注册日期2005-03-26
  • 发帖数94
  • QQ
  • 铜币578枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1480回复:1

ArcObject中数据表通过关键字相关联操作用哪个接口

楼主#
更多 发布于:2007-10-22 16:49
ArcObject中数据表通过关键字相关联操作用哪个接口?
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2007-10-23 11:27
<H1>开发帮助里的例子</H1>
<H1>IRelationship Example</H1><PRE><PRE><CODE><PRE>Option Explicit
Private m_pApp As Application
Private m_pEditor As IEditor

Private Sub Initiate()
  'Use Inititate to set up the environment
  Dim pUID As New UID
  Set m_pApp = Application
  pUID = "esriEditor.editor"
  Set m_pEditor = m_pApp.FindExtensionByCLSID(pUID)
End Sub

Public Sub AttRelValues()
  Dim pFeature As IFeature
  Dim pEnumFeature As IEnumFeature
  Dim pDestFeature As IFeature
  Dim pRelClass As IRelationshipClass
  Dim pEnumRelClass As IEnumRelationshipClass
  Dim pRelSet As ISet
  Dim pAttTable As ITable
  Dim pRelationship As IRelationship
  Dim pRow As IRow
  Dim vAttValue As Variant

  'Call the initiate to set up the environment
  Initiate

  'Check for the right setup
  If Not m_pEditor.EditState = esriStateEditing Then Exit Sub
  If m_pEditor.SelectionCount = 0 Then Exit Sub

  'Get the selected feature
  Set pEnumFeature = m_pEditor.Map.FeatureSelection
  Set pFeature = pEnumFeature.Next
  
  'Assume that only one RC exists for the Origin FC
  Set pEnumRelClass = pFeature.Class.RelationshipClasses(esriRelRoleAny)
  Set pRelClass = pEnumRelClass.Next
  'If a feature with no Relationships established has been selected, Exit
  If pRelClass Is Nothing Then Exit Sub
  Set pRelSet = pRelClass.GetObjectsRelatedToObject(pFeature)
  pRelSet.Reset

  'If an Attributed Relationship does not exist, Exit
  If Not pRelClass.IsAttributed Then Exit Sub
  Set pDestFeature = pRelSet.Next
  While Not pDestFeature Is Nothing
    Set pRelationship = pRelClass.GetRelationship(pFeature, pDestFeature)
  
    Set pRow = pRelationship             'QI
    If IsNull(pRow.Value(0)) Then
       vAttValue = "0"
    Else
       vAttValue = pRow.Value(0)
    End If
    
    MsgBox "Destination OID: " ; pRelationship.DestinationObject.Value(0) ; vbCr ; _
    "Origin OID: " ; pRelationship.OriginObject.Value(0) ; vbCr ; _
    "Attribute value: " ; vAttValue, , "Attributed Relationship Value"

    Set pDestFeature = pRelSet.Next
  Wend
End Sub</PRE></CODE></PRE></PRE>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部