Option Explicit On Imports Inventor Public Class clsSelect Public ThisApplication As Inventor.Application ' Declare the event objects Private WithEvents oInteractEvents As InteractionEvents Private WithEvents oSelectEvents As SelectEvents ' Declare a flag that's used to determine when selection stops. Private bStillSelecting As Boolean Public Function Pick(ByVal filter As SelectionFilterEnum) As Object ' Initialize flag. bStillSelecting = True ' Try to get an active instance of Inventor Try ThisApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") Catch ex As Exception MsgBox("Inventor muss gestartet sein!") End End Try ' Create an InteractionEvents object. oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents ' Ensure interaction is enabled. oInteractEvents.InteractionDisabled = False ' Set a reference to the select events. oSelectEvents = oInteractEvents.SelectEvents ' Set the filter using the value passed in. oSelectEvents.AddSelectionFilter(filter) ' Start the InteractionEvents object. oInteractEvents.Start() ' Loop until a selection is made. Do While bStillSelecting ThisApplication.UserInterfaceManager.DoEvents() Loop Dim oSelectedEnts As ObjectsEnumerator oSelectedEnts = oSelectEvents.SelectedEntities ' Stop the InteractionEvents object. oInteractEvents.Stop() ' Clean up. oSelectEvents = Nothing oInteractEvents = Nothing 'Return: If oSelectedEnts.Count > 0 Then Pick = oSelectedEnts.Item(1) Else Pick = Nothing End If End Function 'SelectionFilterEnum ' kPartEdgeFilter = 15873 ' kPartEdgeCircularFilter = 15874 ' kPartEdgeLinearFilter = 15875 ' kPartEdgeMidpointFilter = 15876 ' kPartFaceFilter = 15877 ' kPartFacePlanarFilter = 15878 ' kPartFaceCylindricalFilter = 15879 ' kPartFaceConicalFilter = 15880 ' kPartFaceToroidalFilter = 15881 ' kPartFaceSphericalFilter = 15882 ' kPartVertexFilter = 15883 ' kPartFeatureFilter = 15884 ' kPartSurfaceFeatureFilter = 15885 ' kPartBodyFilter = 15890 ' kPartDefaultFilter = 15886 ' kSketchDimConstraintFilter = 16128 ' kSketchCurveFilter = 16129 ' kSketchCurveLinearFilter = 16130 ' kSketchCurveCircularFilter = 16131 ' kSketchCurveEllipseFilter = 16132 ' kSketchCurveSplineFilter = 16133 ' kSketchPointFilter = 16134 ' kSketchDefaultFilter = 16135 ' kSketchObjectFilter = 16136 ' kSketchImageFilter = 16137 ' kSketchTextBoxFilter = 16138 ' kSketchProfileFilter = 16139 ' kSketchProjectedCutFilter = 16140 ' kSketchBlockDefinitionFilter = 16141 ' kSketchBlockFilter = 16142 ' kSketch3DCurveFilter = 17664 ' kSketch3DCurveLinearFilter = 17665 ' kSketch3DCurveCircularFilter = &H4502 ' kSketch3DCurveEllipseFilter = 17667 ' kSketch3DCurveSplineFilter = 17668 ' kSketch3DPointFilter = 17669 ' kSketch3DDefaultFilter = 17670 ' kSketch3DObjectFilter = 17671 ' kSketch3DDimConstraintFilter = &H4508 ' kSketch3DProfileFilter = 17673 ' kWorkAxisFilter = 16384 ' kWorkPlaneFilter = 16385 ' kWorkPointFilter = 16386 ' kUserCoordinateSystemFilter = 16387 ' kAssemblyOccurrenceFilter = 16640 ' kAssemblyLeafOccurrenceFilter = 16643 ' kAssemblyOccurrencePatternFilter = 16644 ' kAssemblyOccurrencePatternElementFilter = 16645 ' kAssemblyFeatureFilter = 16646 ' kAllPlanarEntities = 18432 ' kAllLinearEntities = 18433 ' kAllPointEntities = 18434 ' kAllCircularEntities = 18435 ' kAllCustomGraphicsFilter = 18436 ' kCustomBrowserNodeFilter = 18437 ' kFeatureDimensionFilter = 18438 ' kDrawingDefaultFilter = 16896 ' kDrawingSheetFilter = 16897 ' kDrawingViewFilter = 16898 ' kDrawingNoteFilter = 16899 ' kDrawingDimensionFilter = 16900 ' kDrawingPartsListFilter = 16901 ' kDrawingHoleTableFilter = 16902 ' kDrawingHoleTagFilter = 16903 ' kDrawingRevisionTableFilter = 16904 ' kDrawingCustomTableFilter = 16905 ' kDrawingBalloonFilter = 16906 ' kDrawingSketchedSymbolFilter = 16907 ' kDrawingSketchedSymbolDefinitionFilter = 16908 ' kDrawingBorderDefinitionFilter = 16909 ' kDrawingTitleBlockDefinitionFilter = 16910 ' kDrawingBorderFilter = 16913 ' kDrawingTitleBlockFilter = 16912 ' kDrawingCurveSegmentFilter = 16914 ' kDrawingCenterlineFilter = 16915 ' kDrawingCentermarkFilter = 16916 ' kDrawingSheetFormatFilter = 16917 ' kDrawingFeatureControlFrameFilter = 16918 ' kDrawingSurfaceTextureSymbolFilter = 16919 ' kDrawingOriginIndicatorFilter = 16920 ' kDrawingViewLabelFilter = 16921 Private Sub oInteractEvents_OnTerminate() Handles oInteractEvents.OnTerminate ' Set the flag to indicate we're done. bStillSelecting = False End Sub Private Sub oSelectEvents_OnSelect(ByVal JustSelectedEntities As Inventor.ObjectsEnumerator, ByVal SelectionDevice As Inventor.SelectionDeviceEnum, ByVal ModelPosition As Inventor.Point, ByVal ViewPosition As Inventor.Point2d, ByVal View As Inventor.View) Handles oSelectEvents.OnSelect ' Set the flag to indicate we're done. bStillSelecting = False End Sub End Class