Selecting Ordinate Dimension Members using Select Set

Selecting Ordinate Dimension Members using Select Set

inulobo
Advocate Advocate
453 Views
3 Replies
Message 1 of 4

Selecting Ordinate Dimension Members using Select Set

inulobo
Advocate
Advocate

Is there a way to use the select set selection box to grab only the members of an ordinate dimension set that are in the selection box? I am trying to find a way to select a few then do something then select a few more different members and do something. I do not want to do something to the entire set. 

0 Likes
454 Views
3 Replies
Replies (3)
Message 2 of 4

inulobo
Advocate
Advocate

Here is a picture of what I mean

inulobo_1-1613063731362.png

Is there a way to get the start point and endpoint of the selection?

0 Likes
Message 3 of 4

JelteDeJong
Mentor
Mentor

this rule will let you select ordinate dimension

Public Class ThisRule
    Sub Main()
        Dim oSelect As New Selector
        Dim selectedItems As ObjectsEnumerator = oSelect.Pick(ThisApplication)
        If selectedItems Is Nothing Then Return

		' selectedItems holds all of your Ordinate Dimension

        Dim oSelSet As SelectSet = ThisApplication.ActiveDocument.SelectSet
        oSelSet.Clear()
        For Each oFace In selectedItems
            oSelSet.Select(oFace)
        Next
    End Sub
End Class


Public Class Selector
    ' taken from:
    ' https://adndevblog.typepad.com/manufacturing/2016/07/filter-out-faces-not-facing-the-user.html

    Private WithEvents oInteractEvents As InteractionEvents
    Private WithEvents oSelectEvents As SelectEvents
    Private bStillSelecting As Boolean
	Private Sub oSelectEvents_OnPreSelect(
                ByRef PreSelectEntity As Object,
                ByRef DoHighlight As Boolean,
                ByRef MorePreSelectEntities As ObjectCollection,
                SelectionDevice As SelectionDeviceEnum,
                ModelPosition As Point,
                ViewPosition As Point2d, View As Inventor.View)
		
		'here we check if a selected item is of the type OrdinateDimension
        If Not TypeOf PreSelectEntity Is OrdinateDimension Then
            DoHighlight = False
            Exit Sub
        Else
            DoHighlight = True
        End If
    End Sub
	
    Public Function Pick(ThisApplication As Inventor.Application) As ObjectsEnumerator
        bStillSelecting = True
        oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents
        oInteractEvents.InteractionDisabled = False
        oSelectEvents = oInteractEvents.SelectEvents
        oSelectEvents.WindowSelectEnabled = True

        AddHandler oSelectEvents.OnPreSelect, AddressOf oSelectEvents_OnPreSelect
        AddHandler oSelectEvents.OnSelect, AddressOf oSelectEvents_OnSelect
        AddHandler oInteractEvents.OnTerminate, AddressOf oInteractEvents_OnTerminate

        oInteractEvents.Start()

        Do While bStillSelecting
            ThisApplication.UserInterfaceManager.DoEvents()
        Loop

        Dim oSelectedEnts As ObjectsEnumerator
        oSelectedEnts = oSelectEvents.SelectedEntities
        If oSelectedEnts.Count > 0 Then
            Pick = oSelectedEnts
        Else
            Pick = Nothing
        End If

        oInteractEvents.Stop()
        oSelectEvents = Nothing
        oInteractEvents = Nothing
    End Function

    Private Sub oInteractEvents_OnTerminate()
        bStillSelecting = False
    End Sub
    Private Sub oSelectEvents_OnSelect(
            ByVal JustSelectedEntities As ObjectsEnumerator,
            ByVal SelectionDevice As SelectionDeviceEnum,
            ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As Inventor.View)
        bStillSelecting = False
    End Sub
End Class

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 4 of 4

inulobo
Advocate
Advocate

Thank you but that's not exactly what I'm looking for. I don't want an ilogic rule. I want to do this is vba using API. In any case, I could not get your code to work. Thank you for the suggestion though. 

0 Likes