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


Loop On The Schematic Attributes Related To A Schematic Element Class Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Loop On The Schematic Attributes Related To A Schematic Element Class Snippet

Looping on all the schematic attributes related to a given SchematicElementClass

[C#]
        /// <summary>
        /// Looping on all the schematic attributes related to a SchematicElementClass
        /// </summary>
        /// <param name="schemElementClass">The SchematicElementClass the attributes are related to</param>
        public void SchematicAttributeFromElementClass(ESRI.ArcGIS.Schematic.ISchematicElementClass schemElementClass)
        {
                // cast SchematicElementClass into ISchematicAttributeContainer
                ESRI.ArcGIS.Schematic.ISchematicAttributeContainer schAttributeCont=(ESRI.ArcGIS.Schematic.ISchematicAttributeContainer)schemElementClass;

                // retrieve all the SchematicAttribute in the schematic attribute container
                ESRI.ArcGIS.Schematic.IEnumSchematicAttribute enumAttribute=schAttributeCont.SchematicAttributes;
                enumAttribute.Reset();

                // get the first SchematicAttribute
                ESRI.ArcGIS.Schematic.ISchematicAttribute schAttribute=enumAttribute.Next();
                bool isOk=false;
                while (schAttribute != null)
                {
                        // TODO: add your code here, set isOk to true to exit the loop

                        if (isOk) break;

                        // get the next SchematicAttribute
                        schAttribute=enumAttribute.Next();
                }
        }
[Visual Basic .NET]
        ''' <summary>
        ''' Looping on all the schematic attributes related to a SchematicElementClass
        ''' </summary>
        ''' <param name="schemElementClass">The SchematicElementClass the attributes are related to</param>
        ''' <remarks></remarks>
        Public Sub SchematicAttributeFromElementClass(ByVal schemElementClass As ESRI.ArcGIS.Schematic.ISchematicElementClass)

                ' cast SchematicElementClass into ISchematicAttributeContainer
                Dim schAttributeCont As ESRI.ArcGIS.Schematic.ISchematicAttributeContainer=TryCast(schemElementClass, ESRI.ArcGIS.Schematic.ISchematicAttributeContainer)

                ' retrieve all the SchematicAttribute in the schematic attribute container
                Dim enumAttribute As ESRI.ArcGIS.Schematic.IEnumSchematicAttribute=schAttributeCont.SchematicAttributes
                enumAttribute.Reset()
        
                ' get the first SchematicAttribute
                Dim schAttribute As ESRI.ArcGIS.Schematic.ISchematicAttribute=enumAttribute.Next()
                Dim isOk As Boolean=False
                While (schAttribute IsNot Nothing)
                        ' TODO: add your code here, set isOk to True to exit the loop

                        If (isOk) Then Exit While

                        ' get the next SchematicAttribute
                        schAttribute=enumAttribute.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