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


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

Change An In-Memory Sublink Schematic Feature Origin Node Snippet

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

[C#]
        /// <summary>
        /// Change the origin node of an in-memory schematic sublink
        /// </summary>
        /// <param name="schemSubLink">The ISchematicInMemoryFeatureSubLink which origin node must be changed</param>
        /// <param name="newFromNode">The newFromNode origin node object</param>
        public void ChangeFromNodeOfSubLink(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureSubLink schemSubLink, object newFromNode)
        {
                // verify that the input newFromNode object is a SchematicInMemoryFeatureNode 
                ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode schNode=(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode)newFromNode;
                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: newFromNode is either a SchematicInMemoryFeatureNode or a SchematicInMemoryFeatureNodeOnLink           
                // case#1: newFromNode 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)newFromNode;

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

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


                // case#2: newFromNode 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 origin node change can be done
                                schLink.FromNode=schNode;
                                return;
                        }
                        schLink=schLinks.Next();
                }
        }
[Visual Basic .NET]
        ''' <summary>
        ''' Change the origin node of an in-memory schematic sublink
        ''' </summary>
        ''' <param name="schemSubLink">The ISchematicInMemoryFeatureSubLink which origin node must be changed</param>
        ''' <param name="newFromNode">The newFromNode origin node object</param>
        Public Sub ChangeFromNodeOfSubLink(ByVal schemSubLink As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureSubLink, ByVal newFromNode As Object)

                ' verify that the input newFromNode object is a SchematicInMemoryFeatureNode
                Dim schNode As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode=TryCast(newFromNode, 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: newFromNode is either a SchematicInMemoryFeatureNode or a SchematicInMemoryFeatureNodeOnLink
                ' case#1: newFromNode is a SchematicInMemoryFeatureNodeOnLink; its reference link and the sublink reference link must be the same
                Try

                        Dim schNodeOnLink As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNodeOnLink=TryCast(newFromNode, ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNodeOnLink)

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

                        ' then return whether the conditions are verified or not
                        Return

                Catch
                End Try

                ' case#2: newFromNode 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 origin node change can be done
                                schLink.FromNode=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