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


Loop On The Schematic Elements In A Schematic Diagram Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Loop On The Schematic Elements In A Schematic Diagram Snippet

Looping on all the schematic elements contained in a SchematicDiagram

[C#]
        /// <summary>
        /// Looping on all the schematic elements contained in a SchematicDiagram
        /// </summary>
        /// <param name="schemDiagram">The SchematicDiagram which contains the schematic elements</param>
        public void SchematicElementsFromDiagram(ESRI.ArcGIS.Schematic.ISchematicDiagram schemDiagram)
        {
                 // cast SchematicDiagram into ISchematicElementContainer
                ESRI.ArcGIS.Schematic.ISchematicElementContainer schElemCont=(ESRI.ArcGIS.Schematic.ISchematicElementContainer)schemDiagram;

                // retrieve all the SchematicElement in the schematic diagram container
                ESRI.ArcGIS.Schematic.IEnumSchematicElement enumElement=schElemCont.SchematicElements;

                enumElement.Reset();
                // get the first SchematicElement
                ESRI.ArcGIS.Schematic.ISchematicElement schElement=enumElement.Next();
                bool isOk=false;
                while (schElement != null)
                {
                        // TODO: add your code here, set isOk to true to exit the loop

                        if (isOk) break;

                        // get the next SchematicElement
                        schElement=enumElement.Next();
                }
        }
[Visual Basic .NET]
        ''' <summary>
        ''' Looping on all the schematic elements contained in a SchematicDiagram
        ''' </summary>
        ''' <param name="schemDiagram">The SchematicDiagram which contains the schematic elements</param>
        Public Sub SchematicElementsFromDiagram(ByVal schemDiagram As ESRI.ArcGIS.Schematic.ISchematicDiagram)
                ' cast SchematicDiagram into ISchematicElementContainer
                Dim schElemCont As ESRI.ArcGIS.Schematic.ISchematicElementContainer=TryCast(schemDiagram, ESRI.ArcGIS.Schematic.ISchematicElementContainer)

                ' retrieve all the SchematicElement in the schematic diagram container
                Dim enumElement As ESRI.ArcGIS.Schematic.IEnumSchematicElement=schElemCont.SchematicElements

                enumElement.Reset()
                ' get the first SchematicElement
                Dim schElement As ESRI.ArcGIS.Schematic.ISchematicElement=enumElement.Next()
                Dim isOk As Boolean=False
                While (schElement IsNot Nothing)
                        ' TODO: add your code here, set isOk to true to exit the loop

                        If (isOk) Then Exit While

                        ' get the next SchematicElement
                        schElement=enumElement.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