Solid Edge Framework Type Library
ActiveSelectSet Property
Solid Edge Framework Type Library > Application Object : ActiveSelectSet Property
Description
Returns the SelectSet object for the currently active window.
Property type
Read-only property
Syntax
Visual Basic
Public Property ActiveSelectSet As SelectSet
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

            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)

                ' ActiveSelectSet will throw an exception if no document is open.
                Dim activeSelectSet = application.ActiveSelectSet

                ' Loop through the items.
                For i As Integer = 1 To activeSelectSet.Count
                    Dim item = activeSelectSet.Item(i)

                    ' Get the .NET runtime type. It will always be a System.__ComObject.
                    Dim itemType = item.GetType()

                    ' Using the .NET runtime type, get the Type property of the object.
                    Dim objectType = itemType.InvokeMember("Type", System.Reflection.BindingFlags.GetProperty, Nothing, item, Nothing)

                    ' Typically the return value will map to a SolidEdgeConstants.ObjectType.
                    Select Case CType(objectType, SolidEdgeConstants.ObjectType)
                        Case SolidEdgeConstants.ObjectType.igDrawingView
                            Dim drawingView = CType(item, SolidEdgeDraft.DrawingView)
                        Case SolidEdgeConstants.ObjectType.igPart
                            Dim occurrence1 = CType(item, SolidEdgeAssembly.Occurrence)
                        Case SolidEdgeConstants.ObjectType.igSubAssembly
                            Dim occurrence2 = CType(item, SolidEdgeAssembly.Occurrence)
                        Case Else
                            ' For Part & SheetMetal environments, the type could map to a SolidEdgeConstants.FeatureTypeConstants.
                            Select Case CType(objectType, SolidEdgeConstants.FeatureTypeConstants)
                                Case SolidEdgeConstants.FeatureTypeConstants.igChamferFeatureObject
                                    Dim chamfer = CType(item, SolidEdgePart.Chamfer)
                                Case SolidEdgeConstants.FeatureTypeConstants.igExtrudedProtrusionFeatureObject
                                    Dim extrudedProtrusion = CType(item, SolidEdgePart.ExtrudedProtrusion)
                                Case SolidEdgeConstants.FeatureTypeConstants.igRevolvedProtrusionFeatureObject
                                    Dim revolvedProtrusion = CType(item, SolidEdgePart.RevolvedProtrusion)
                            End Select
                    End Select
                Next i
            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;

            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");

                // ActiveSelectSet will throw an exception if no document is open.
                var activeSelectSet = application.ActiveSelectSet;

                // Loop through the items.
                for (int i = 1; i <= activeSelectSet.Count; i++)
                {
                    var item = activeSelectSet.Item(i);

                    // Get the .NET runtime type. It will always be a System.__ComObject.
                    var itemType = item.GetType();

                    // Using the .NET runtime type, get the Type property of the object.
                    var objectType = itemType.InvokeMember("Type", System.Reflection.BindingFlags.GetProperty, null, item, null);

                    // Typically the return value will map to a SolidEdgeConstants.ObjectType.
                    switch ((SolidEdgeConstants.ObjectType)objectType)
                    {
                        case SolidEdgeConstants.ObjectType.igDrawingView:
                            var drawingView = (SolidEdgeDraft.DrawingView)item;
                            break;
                        case SolidEdgeConstants.ObjectType.igPart:
                            var occurrence1 = (SolidEdgeAssembly.Occurrence)item;
                            break;
                        case SolidEdgeConstants.ObjectType.igSubAssembly:
                            var occurrence2 = (SolidEdgeAssembly.Occurrence)item;
                            break;
                        default:
                            // For Part & SheetMetal environments, the type could map to a SolidEdgeConstants.FeatureTypeConstants.
                            switch ((SolidEdgeConstants.FeatureTypeConstants)objectType)
                            {
                                case SolidEdgeConstants.FeatureTypeConstants.igChamferFeatureObject:
                                    var chamfer = (SolidEdgePart.Chamfer)item;
                                    break;
                                case SolidEdgeConstants.FeatureTypeConstants.igExtrudedProtrusionFeatureObject:
                                    var extrudedProtrusion = (SolidEdgePart.ExtrudedProtrusion)item;
                                    break;
                                case SolidEdgeConstants.FeatureTypeConstants.igRevolvedProtrusionFeatureObject:
                                    var revolvedProtrusion = (SolidEdgePart.RevolvedProtrusion)item;
                                    break;
                            }
                            break;
                    }
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                OleMessageFilter.Unregister();
            }
        }
    }
}
See Also

Application Object  | Application Members