Author Topic: Custom menu in default ContextMenu group  (Read 2062 times)

0 Members and 1 Guest are viewing this topic.

dull_blades

  • Guest
Custom menu in default ContextMenu group
« on: November 01, 2011, 03:54:27 PM »
Asked this over in the Autodesk discussion groups with no answers, so I thought I would try here as well.

I have code that adds my own custom menu group to a contextmenu when right-clicking with a particular object selected (in this case a dimension).  Works great!
 
My questions are:
 
1) How can I get my custom menu item located where I want it rather than appearing where it wants in the contextmenu?
 
2) Can I add my own custom menu item to an existing context menu group?  For example:  It you right-click on a dimension string in AutoCAD 2012, you get a group of dimension commands: Dimension Style, Precision, Etc...  Is it possible to add my menu item to that group?  If so, how can I do this.  I cannot seem to find it documented anywhere!  Below is my code for adding my own menu group. (Got help from an API Webcast). See attached image for an example of what I want to do.
 
Code: [Select]
Private Sub AddObject_RightClickMenu()

        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor

        Try

            m_ObjectMenu = New ContextMenuExtension

            m_ObjectMenu.Title = "Dimension Objects Menu"

            Dim mnuItem As MenuItem = New MenuItem("Extension Line Toggle")

            AddHandler mnuItem.Click, AddressOf run_dimExtEdit_WhenClicked

            m_ObjectMenu.MenuItems.Add(mnuItem)
            ' create an rxclass           
            Dim dimensionClass As RXClass = RXObject.GetClass(GetType(Dimension))
            ' adding the object menu           
            Application.AddObjectContextMenuExtension(dimensionClass, m_ObjectMenu)

        Catch ex As System.Exception

            ed.WriteMessage("Error Adding Object Menu: " + ex.Message)

        End Try

End Sub

I think I saw somewhere that Kean said #1 is not possible with the AutoCAD API, but I am still not sure about #2.


TIA!

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Custom menu in default ContextMenu group
« Reply #1 on: November 02, 2011, 10:04:47 AM »
Can you edit the cui file with .NET?
 

dull_blades

  • Guest
Re: Custom menu in default ContextMenu group
« Reply #2 on: November 02, 2011, 11:40:22 AM »
Sweet!  How did you do that! 

I guess I have never tried to edit the CUI, so I will look in that direction!


Thanks!

Rob

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Custom menu in default ContextMenu group
« Reply #3 on: November 02, 2011, 11:51:50 AM »
CUI Command then drag to postion you want
 

dull_blades

  • Guest
Re: Custom menu in default ContextMenu group
« Reply #4 on: November 02, 2011, 12:03:38 PM »
Ahhh... I see.  You did that manually?

Even though my custom menu item has been added via .NET, it does not appear in the Acad.cuix (at least I cannot seem to find it).  So not sure that is a viable option.

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Custom menu in default ContextMenu group
« Reply #5 on: November 02, 2011, 12:47:33 PM »
I have not messed with much but with the AcCUI.dll(CUI API) you might be able to.
Maybe someone knows if it is possible or not?

dull_blades

  • Guest
Re: Custom menu in default ContextMenu group
« Reply #6 on: November 02, 2011, 05:34:25 PM »
Thanks for helping Jeff!

I will continue to look for a solution!