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


Get The In-Memory Schematic Features In A Schematic Layer Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Get The In-Memory Schematic Features In A Schematic Layer Snippet

Retrieve all the in-memory schematic features based on a given Schematic Element Class from a schematic layer

[C#]
        ///<summary>Retrieve all the in-memory features based on a given Schematic Element Class from a schematic layer</summary>
        /// 
        ///<param name="schemLayer">The ISchematicLayer from which the function has to get the in-memory features</param>
        ///<param name="ClassName">The name of the schematic element class</param>
        ///
        ///<returns>The retrieved IEnumSchematicInMemoryFeature</returns>
        /// 
        ///<remarks></remarks>
        public ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeature GetInMemoryFeaturesFromSchematicLayerByClassName(ESRI.ArcGIS.Schematic.ISchematicLayer schemLayer, string ClassName)
        {
            // cast the SchematicInMemoryDiagram related to the schematic layer into ISchematicInMemoryFeatureClassContainer
                ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureClassContainer schFeatureCont=(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureClassContainer)schemLayer.SchematicInMemoryDiagram;
                if (schFeatureCont == null) return null;

                // get all the schematic in-memory feature classes related to the schematic layer
                ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeatureClass enuFeatureCont=schFeatureCont.SchematicInMemoryFeatureClasses;
                enuFeatureCont.Reset();

                ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureClass schFeatClass=enuFeatureCont.Next();
                while (schFeatClass != null)
                {
                        if (schFeatClass.SchematicElementClass.Name == ClassName)
                        {
                                return schFeatClass.SchematicInMemoryFeatures;
                        }
                        schFeatClass=enuFeatureCont.Next();
                }

                return null;
        }
[Visual Basic .NET]
        ''' <summary>
        ''' Retrieve all the in-memory features based on a given Schematic Element Class from a schematic layer
        ''' </summary>
        ''' <param name="schemLayer">The ISchematicLayer from which the function has to get the in-memory features</param>
        ''' <param name="ClassName">The name of the schematic element class</param>
        ''' <returns>The retrieved IEnumSchematicInMemoryFeature</returns>
        ''' <remarks></remarks>
        Public Function GetInMemoryFeaturesFromSchematicLayerByClassName(ByVal schemLayer As ESRI.ArcGIS.Schematic.ISchematicLayer, ByVal ClassName As String) As ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeature

                ' cast the SchematicInMemoryDiagram related to the schematic layer into ISchematicInMemoryFeatureClassContainer
                Dim schFeatureCont As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureClassContainer=TryCast(schemLayer.SchematicInMemoryDiagram, ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureClassContainer)
                If schFeatureCont Is Nothing Then Return Nothing

                ' get all the schematic in-memory feature classes related to the schematic layer
                Dim enuFeatureCont As ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeatureClass=schFeatureCont.SchematicInMemoryFeatureClasses
                enuFeatureCont.Reset()

                Dim schFeatClass As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureClass=enuFeatureCont.Next()
                While (schFeatClass IsNot Nothing)
                        If (schFeatClass.SchematicElementClass.Name=ClassName) Then
                                Return schFeatClass.SchematicInMemoryFeatures
                        End If
                        schFeatClass=enuFeatureCont.Next()
                End While

                Return Nothing
        End Function

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