This document is archived and information here might be outdated.  Recommended version.


Change An In-Memory Sublink Schematic Feature Extremity Node Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Change An In-Memory Sublink Schematic Feature Extremity Node Snippet

Change the extremity node of an in-memory schematic feature sublink

[C#]
        /// <summary>
        /// Change the extremity node of an in-memory schematic sublink
        /// </summary>
        /// <param name="schemSubLink">The ISchematicInMemoryFeatureSubLink which extremity node must be changed</param>
        /// <param name="newToNode">The newToNode extremity node object</param>
        public void ChangeToNodeOfSubLink(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureSubLink schemSubLink, object newToNode)
        {

                // verify that the input newToNode object is a SchematicInMemoryFeatureNode
                ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode schNode=(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode)newToNode;
                if (schNode == null)
                        return;

                // cast SchematicInMemoryFeatureSubLink.ReferenceLink into ISchematicInMemoryFeatureLink
                ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink schLinkRef=schemSubLink.ReferenceLink;

                ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink schLink;

                // there are two cases: newToNode is either a SchematicInMemoryFeatureNode or a SchematicInMemoryFeatureNodeOnLink
                // case#1: newToNode is a SchematicInMemoryFeatureNodeOnLink; its reference link and the sublink reference link must be the same
                try
                {
                        ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNodeOnLink schNodeOnLink=(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNodeOnLink)newToNode;

                        schLink=schNodeOnLink.ReferenceLink;
                        if (schLink == schLinkRef)
                                // since case#1 conditions are verified, the extremity node change can be done
                                schLink.ToNode=schNode;

                        // then return whether the conditions are verified or not
                         return;
                
                }
                catch { }


                // case#2: newToNode is a SchematicInMemoryFeatureNode; the sublink reference link must be connected to that node
                ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeatureLink schLinks=schNode.GetIncidentLinks(ESRI.ArcGIS.Schematic.esriSchematicEndPointType.esriSchematicOriginOrExtremityNode);
                schLinks.Reset();
                schLink=schLinks.Next();
                while (schLink != null)
                {
                        if (schLink == schLinkRef)
                        {
                                // since case#2 conditions are verified, the extremity node change can be done
                                schLink.ToNode=schNode;
                                return;
                        }
                        schLink=schLinks.Next();
                }
        }
[Visual Basic .NET]
        ''' <summary>
        ''' Change the extremity node of an in-memory schematic sublink
        ''' </summary>
        ''' <param name="schemSubLink">The ISchematicInMemoryFeatureSubLink which extremity node must be changed</param>
        ''' <param name="newToNode">The newToNode extremity node object</param>
        Public Sub ChangeToNodeOfSubLink(ByVal schemSubLink As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureSubLink, ByVal newToNode As Object)

                ' verify that the input newToNode object is a SchematicInMemoryFeatureNode
                Dim schNode As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode=TryCast(newToNode, ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode)
                If (schNode Is Nothing) Then
                        Exit Sub
                End If

                ' cast SchematicInMemoryFeatureSubLink.ReferenceLink into ISchematicInMemoryFeatureLink
                Dim schLinkRef As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink=schemSubLink.ReferenceLink

                Dim schLink As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink

                ' there are two cases: newToNode is either a SchematicInMemoryFeatureNode or a SchematicInMemoryFeatureNodeOnLink
                ' case#1: newToNode is a SchematicInMemoryFeatureNodeOnLink; its reference link and the sublink reference link must be the same
                Try
                        ' newFromNode is a SchematicInMemoryFeatureNodeOnLink
                        Dim schNodeOnLink As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNodeOnLink=TryCast(newToNode, ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNodeOnLink)

                        schLink=schNodeOnLink.ReferenceLink
                        If (schLink Is schLinkRef) Then
                                ' since case#1 conditions are verified, the extremity node change can be done
                                schLink.ToNode=schNode
                        End If

                        ' then return whether the conditions are verified or not
                         Return

                Catch
                End Try

                ' case#2: newToNode is a SchematicInMemoryFeatureNode; the sublink reference link must be connected to that node
                Dim schLinks As ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeatureLink=schNode.GetIncidentLinks(ESRI.ArcGIS.Schematic.esriSchematicEndPointType.esriSchematicOriginOrExtremityNode)
                schLinks.Reset()
                schLink=schLinks.Next()
                While (schLink IsNot Nothing)
                        If (schLink Is schLinkRef) Then
                                ' since case#2 conditions are verified, the extremity node change can be done
                                schLink.ToNode=schNode
                                Return
                        End If
                        schLink=schLinks.Next()
                End While
        End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Schematic