Author Topic: add to right click menu  (Read 2853 times)

0 Members and 1 Guest are viewing this topic.

HelpLispinSeattle

  • Guest
add to right click menu
« on: May 22, 2009, 09:43:35 AM »
Hello,

It there a way to add/insert an item/command in the default right click menu
without editing the cui? I dont want to create my own (I've seen code
here that allows me to do that). I want to use the default one.

It will be different everytime. Lets say I want to rotate my crosshair 45 degrees.
In my code to rotate the variable "snapang" to 45 degress I want code to also be
able to put/add/insert a command in the right click menu to rotate it back to 0.

Any ideas?

Patrick_35

  • Guest
Re: add to right click menu
« Reply #1 on: May 25, 2009, 05:54:40 AM »
Hi

With [ and ]

An example
Code: [Select]
(getkword "Test [Opt1/Opt2/Opt3]")
@+

HelpLispinSeattle

  • Guest
Re: add to right click menu
« Reply #2 on: May 26, 2009, 09:41:21 PM »
Patrick,

I dont understand. How can you hook this code with the default
right click menu?

Patrick_35

  • Guest
Re: add to right click menu
« Reply #3 on: May 27, 2009, 11:52:05 AM »
You have options in right click menu

With my example you have Opt1,Opt2 and Opt3

@+

HelpLispinSeattle

  • Guest
Re: add to right click menu
« Reply #4 on: May 28, 2009, 07:56:51 AM »
Patrick,

I need to add them to the "Default menu" not the "Command menu".
Thank you anyway. I guess it  just cant be done.

cjw

  • Guest

HelpLispinSeattle

  • Guest
Re: add to right click menu
« Reply #6 on: June 01, 2009, 04:05:53 PM »
cjw,

Thank you.

HelpLispinSeattle

  • Guest
Re: add to right click menu
« Reply #7 on: June 11, 2009, 08:34:49 AM »
Hello again,

I was able to find a lisp program that can do what I was looking for. It adds
an item on top of Acad's menu defaut right click.


Problem:
Whenever I select "RotCrHr45" again this error message comes up. I dont know
how to fix it.

error: Automation Error. Menu item with label Rotate CrossHairs 45 degrees
exists in the popup menu

Can somebody please refine the code to
1. Only add the desire item/s if its not there yet.
2. A sub routine to be able to
   a). Delete the the added item/s.
   b). Reset the default right click menu to original form.

Any help or ideas would be appreciated...


(defun c:RotCrHr45 ()
(if (equal (getvar "snapang") (* 0.017454 45) 0.01)
          (setvar "snapang" 0.0)
          (setvar "snapang" (* 0.017454 45))
)
(addDefaultMenuItem "Rotate CrossHairs 45 degrees" "RotCrHr45 ")
(princ)
)


(defun AddDefaultMenuItem (cmd_desc cmd_todo / acadApp acadMenuGroups Menu)
(setq acadApp (vlax-get-acad-object))
(setq acadMenuGroups (vla-get-MenuGroups acadApp))
(vlax-for MenuGroup acadMenuGroups
(setq Name (vla-get-name MenuGroup))
(if (= Name "ACAD") (setq Menu MenuGroup))
)
(setq PopUps (vla-get-Menus Menu))
(setq CmdDefault nil)
(vlax-for PopUp PopUps
(setq Name (vla-get-name PopUp))
(if (= Name "Default Menu") (setq CmdDefault PopUp))
)
(vla-AddMenuItem CmdDefault 0 cmd_desc cmd_todo)
(princ)
)