阅读:1643回复:1
ArcObject中数据表通过关键字相关联操作用哪个接口
ArcObject中数据表通过关键字相关联操作用哪个接口?
|
|
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> |
|
|