Solid Edge Assembly Type Library
Item Method
Variant (input) index.
Description
The items in a collection.
Syntax
Visual Basic
Public Function Item( _
   ByVal Index As Variant _
) As Object
Parameters
Index
Variant (input) index.
Example
Option Infer On

Imports System
Imports System.Runtime.InteropServices

Namespace Examples
    Friend Class Program
        <STAThread>
        Shared Sub Main(ByVal args() As String)
            Dim application As SolidEdgeFramework.Application = Nothing
            Dim assemblyDocument As SolidEdgeAssembly.AssemblyDocument = Nothing
            Dim relations3d As SolidEdgeAssembly.Relations3d = Nothing

            Try
                ' See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
                OleMessageFilter.Register()

                ' Attempt to connect to a running instance of Solid Edge.
                application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
                assemblyDocument = TryCast(application.ActiveDocument, SolidEdgeAssembly.AssemblyDocument)

                If assemblyDocument IsNot Nothing Then
                    relations3d = assemblyDocument.Relations3d

                    For i As Integer = 1 To relations3d.Count
                        Dim relation3d = relations3d.Item(i)

                        ' Get the runtime time. Will always be System.__ComObject.
                        Dim runtimeType = relation3d.GetType()

                        ' Invoke the Type property of the COM object.
                        Dim objectType = CType(runtimeType.InvokeMember("Type", System.Reflection.BindingFlags.GetProperty, Nothing, relation3d, Nothing), SolidEdgeFramework.ObjectType)

                        ' Now that we know what kind of relation we're working with, we can cast accordingly.
                        Select Case objectType
                            Case SolidEdgeFramework.ObjectType.igAngularRelation3d
                                Dim angularRelation3d = CType(relation3d, SolidEdgeAssembly.AngularRelation3d)
                            Case SolidEdgeFramework.ObjectType.igAxialRelation3d
                                Dim axialRelation3d = CType(relation3d, SolidEdgeAssembly.AxialRelation3d)
                            Case SolidEdgeFramework.ObjectType.igGroundRelation3d
                                Dim groundRelation3d = CType(relation3d, SolidEdgeAssembly.GroundRelation3d)
                        End Select
                    Next i
                End If
            Catch ex As System.Exception
                Console.WriteLine(ex)
            Finally
                OleMessageFilter.Unregister()
            End Try
        End Sub
    End Class
End Namespace
using System;
using System.Runtime.InteropServices;

namespace Examples
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Relations3d relations3d = null;

            try
            {
                // See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
                OleMessageFilter.Register();

                // Attempt to connect to a running instance of Solid Edge.
                application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
                assemblyDocument = application.ActiveDocument as SolidEdgeAssembly.AssemblyDocument;

                if (assemblyDocument != null)
                {
                    relations3d = assemblyDocument.Relations3d;

                    for (int i = 1; i <= relations3d.Count; i++)
                    {
                        var relation3d = relations3d.Item(i);

                        // Get the runtime time. Will always be System.__ComObject.
                        var runtimeType = relation3d.GetType();

                        // Invoke the Type property of the COM object.
                        var objectType = (SolidEdgeFramework.ObjectType)runtimeType.InvokeMember("Type", System.Reflection.BindingFlags.GetProperty, null, relation3d, null);

                        // Now that we know what kind of relation we're working with, we can cast accordingly.
                        switch (objectType)
                        {
                            case SolidEdgeFramework.ObjectType.igAngularRelation3d:
                                var angularRelation3d = (SolidEdgeAssembly.AngularRelation3d)relation3d;
                                break;
                            case SolidEdgeFramework.ObjectType.igAxialRelation3d:
                                var axialRelation3d = (SolidEdgeAssembly.AxialRelation3d)relation3d;
                                break;
                            case SolidEdgeFramework.ObjectType.igGroundRelation3d:
                                var groundRelation3d = (SolidEdgeAssembly.GroundRelation3d)relation3d;
                                break;
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                OleMessageFilter.Unregister();
            }
        }
    }
}
See Also

Relations3d Collection  | Relations3d Members