How to test the marking menu ?

How to test the marking menu ?

TONELLAL
Collaborator Collaborator
439 Views
2 Replies
Message 1 of 3

How to test the marking menu ?

TONELLAL
Collaborator
Collaborator

Hello,

I need to modify the marking menu, but only if a given command is already in it. So I need to test if this command exist in the marking menu. The problem is that the command exist or not, for inventor it always exist ! Here the code I use to test it :

 

Private Sub oUserInputEvents_OnLinearMarkingMenu( _
ByVal SelectedEntities As ObjectsEnumerator, _
ByVal SelectionDevice As SelectionDeviceEnum, _
ByVal LinearMenu As CommandControls, _
ByVal AdditionalInfo As NameValueMap)
'

dim test as boolean

 

'Test on an existing command
test = LinearMenu.item("Delete") Is Nothing

 

'Test on a non-existing command
test = LinearMenu.item("Deletesdfgdsfg") Is Nothing
'
End Sub

 

In both cases, Test = false

 

What's wrong ?

0 Likes
440 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Just a thought, but maybe what you need to check in this situation, instead of 'Is Noting' is the CommandControl.Visible (test = LinearMenu.item("Delete").Visible) , but I don't really know the larger task being dealt with here.  Another probably stupid question...are you sure you need to be working with a LinearMarkingMenu, and not the RadialMarkingMenu?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

TONELLAL
Collaborator
Collaborator

 CommandControl.Visible seems to work only in the ribbon. I tried it, fail...

And yes, I need to use the Linear menu and not the Radial menu,  just because the final goal is to replace an existing command.

I found a workaround with a For loop on Control.internalName, but... strange !

 

Another strange thing about Linear or Radial marking menus :

the command I want to replace is : 

-from the browser, only in the linear menu

-from the graphic window, only in the radial menu.

I can find and replace it in both menus, but adding the new command in the radial menu make it appear in the  Linear menu, even when I modify nothing in the linear menu !!

 

Before menu edition :

TONELLAL_0-1635525238779.png

 

After menu edition. I modified ONLY the radial menu, nothing on the linear menu :

TONELLAL_1-1635525489758.png

 

The code :

Private Sub oUserInputEvents_OnRadialMarkingMenu(ByVal SelectedEntities As ObjectsEnumerator, ByVal SelectionDevice As SelectionDeviceEnum, ByVal RadialMenu As RadialMarkingMenu, ByVal AdditionalInfo As NameValueMap)

Dim TestCommand As String

'Command to replace
TestCommand = "AFG_FrameMember_Edit"

 

'Replacing the command if found
With RadialMenu
If .NorthControl.InternalName = TestCommand Then
.NorthControl = oButtonDef_Modifier_fer
End If

If .NortheastControl.InternalName = "TestCommand" Then
.NortheastControl = oButtonDef_Modifier_fer
End If

If .NorthwestControl.InternalName = TestCommand Then
.NorthwestControl = oButtonDef_Modifier_fer
End If

If .SouthControl.InternalName = TestCommand Then
.SouthControl = oButtonDef_Modifier_fer
End If

If .SoutheastControl.InternalName = TestCommand Then
.SoutheastControl = oButtonDef_Modifier_fer
End If

If .SouthwestControl.InternalName = TestCommand Then
.SouthwestControl = oButtonDef_Modifier_fer
End If
End With

 

Bonus : if you know another way, like "for each control in radialmenu", instead of this... I'm interested !