Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
BrentBurgess1980
Posts: 166
Registered: ‎06-16-2008
Message 1 of 6 (10,914 Views)
Accepted Solution

Show/Hide Menu's in Workspace

10914 Views, 5 Replies
10-17-2012 12:58 AM

I have been programming for a few years in C#, but not in lisp, so forgive me if this has been answered or easy to do.

 

I have a bunch of discipline specific menu files as partial cui's to my enterprise menu. I dont want to show them all, as some users may not need them all. What I would like to have is a menu item

Load Menus ->

                     Civil

                     Electrical

                     Mechanical

                     Structural

 

and when they click on one of them the relevant menu file is made visible in the current workspace.

 

Is there a simple way to do this?

I saw this post, but the menucmd doesnt appear to be recognised command in 2012.

 

Thanks


BrentBurgess1980 wrote:

I have been programming for a few years in C#, but not in lisp, so forgive me if this has been answered or easy to do.

 

I have a bunch of discipline specific menu files as partial cui's to my enterprise menu. I dont want to show them all, as some users may not need them all. What I would like to have is a menu item

Load Menus ->

                     Civil

                     Electrical

                     Mechanical

                     Structural

 

and when they click on one of them the relevant menu file is made visible in the current workspace.

 

Is there a simple way to do this?

I saw this post, but the menucmd doesnt appear to be recognised command in 2012.

 

Thanks


Today is your lucky day as I am investigating this as we speak.

Menucmd does work in R2013 - I just tested this 2 days ago...

 

I am making the assumption you are meaning the MENUBAR, which is called a POP ($Pn=).

If you are talking about the Screen Menu ($S=), the same will almost apply.

 

You will need to create a command, weather it is a line in a POP, a toolbar button, or an accelerator key.

The format to this depends on how your menu is structured as explained below:

 

If you are going the Enterprise route, the following syntax is used:

 Macro = $Pn=MyMenu.MyPop where "n" is the position of the pop (valid numbers are 1 thru 16).

However this will not work as one does not know how many POP's are currently showing,

thus you do not know the position of the POP you want to replace.

 

 Macro = (menucmd "MainMenu.MainPop=+MyMenu.MyPop")

This will "insert and remove" a specific column of the POP where "MainMenu.MainPop" is a

POP that is named anything from POP1 thru POP16 as these will show when first starting.

 

To simply add a POP, where none exists (you are adding, not replacing), the following can be used:

 Macro = (menucmd "P16=+MyMenu.MyPop")

This assures the new POP is added as the last item in the MENUBAR. Please note that this will not

be assigned as POP16 if there are less than 15 POP's currently showing.

 

Now be aware that if you decide to transfer the enterprise menus into the main, as one big menu,

this geometry will have to be revised to reflect the main menu group name. An alternative is to

remove the menu group name prefix from the statement (menucmd "P16=+MyPop").

 

Now the fun part.

 Civil - Assign an Alias as "POP100" (mandatory), and Alias "Civil" where POP menu name.

Assign a Menu Group name of "My_Civil" (you can use the actual file name here).

 Electrical - Alias as "POP200" and "Electrical". Menu Group name is "My_Electrical".

Anything above POP16 to POP999 can be used, and will not display when editor is started.

 

Using what is shown above to insert the civil POP:

 (menucmd "P16=+My_Civil.POP100") or

 (menucmd "P16=+My_Civil.Civil")

 

Using what is shown above to insert and remove:

 (menucmd "My_Civil.POP100=+My_Electrical.POP200")

 

To remove a POP, use this:

 (menucmd "My_Electrical.POP200=-")

 

To make command line quiet, you can try to add a ^P in front of the macro:

 Macro = ^P(menucmd "My_Electrical.POP200=-")  [untested, I never had a use for this until now]

 

 

POP01_2012-10-17.png

 

For this example, this menu is an enterprise to the main ACAD.cui.

POP14 will show when the editor is started, however if I name this to POP140, it will not show and

I will use the following macro to make it display: (menucmd "P16=+JPW98-17CUSTOM.LAYERS")

 

Lastly, one can create a "home" POP that will list all your enterprise POP's. This column will show

when editor is started and then you can use the insert and remove method to display desired menu

in it's place. Go into each POP (civil, elect, etc.) and add a line either at the top or botton (next to a

separator) that will reset back to the "Home" POP.

 

Of course this is untested as I have been tinkering and studying this topic for about a week now.

See AutoCAD's Developers Guide -> Customize the User Interface -> Create Pull-Down and Shortcut

Menus for more information.

 

If you need Screen Menu help, including page swapping and layering, I'll get you there as well.

 

Scot-65

 

*Expert Elite*
hmsilva
Posts: 3,368
Registered: ‎12-17-2004
Message 2 of 6 (10,906 Views)

Re: Show/Hide Menu's in Workspace

10-17-2012 02:55 AM in reply to: BrentBurgess1980

BrentBurgess1980 wrote:

I saw this post, but the menucmd doesnt appear to be recognised command in 2012.


BrentBurgess1980,

menucmd is an autolisp function,
if you type

Command: (menucmd)

you will get

; error: too few arguments

see in
Help > AutoLISP Reference Guide > AutoLISP Functions > M Functions

Henrique

Contributor
bobdobbs
Posts: 15
Registered: ‎09-27-2012
Message 3 of 6 (10,891 Views)

Re: Show/Hide Menu's in Workspace

10-17-2012 04:54 AM in reply to: BrentBurgess1980
*Expert Elite*
scot-65
Posts: 2,210
Registered: ‎12-11-2003
Message 4 of 6 (10,865 Views)

Re: Show/Hide Menu's in Workspace

10-17-2012 04:20 PM in reply to: BrentBurgess1980

BrentBurgess1980 wrote:

I have been programming for a few years in C#, but not in lisp, so forgive me if this has been answered or easy to do.

 

I have a bunch of discipline specific menu files as partial cui's to my enterprise menu. I dont want to show them all, as some users may not need them all. What I would like to have is a menu item

Load Menus ->

                     Civil

                     Electrical

                     Mechanical

                     Structural

 

and when they click on one of them the relevant menu file is made visible in the current workspace.

 

Is there a simple way to do this?

I saw this post, but the menucmd doesnt appear to be recognised command in 2012.

 

Thanks


Today is your lucky day as I am investigating this as we speak.

Menucmd does work in R2013 - I just tested this 2 days ago...

 

I am making the assumption you are meaning the MENUBAR, which is called a POP ($Pn=).

If you are talking about the Screen Menu ($S=), the same will almost apply.

 

You will need to create a command, weather it is a line in a POP, a toolbar button, or an accelerator key.

The format to this depends on how your menu is structured as explained below:

 

If you are going the Enterprise route, the following syntax is used:

 Macro = $Pn=MyMenu.MyPop where "n" is the position of the pop (valid numbers are 1 thru 16).

However this will not work as one does not know how many POP's are currently showing,

thus you do not know the position of the POP you want to replace.

 

 Macro = (menucmd "MainMenu.MainPop=+MyMenu.MyPop")

This will "insert and remove" a specific column of the POP where "MainMenu.MainPop" is a

POP that is named anything from POP1 thru POP16 as these will show when first starting.

 

To simply add a POP, where none exists (you are adding, not replacing), the following can be used:

 Macro = (menucmd "P16=+MyMenu.MyPop")

This assures the new POP is added as the last item in the MENUBAR. Please note that this will not

be assigned as POP16 if there are less than 15 POP's currently showing.

 

Now be aware that if you decide to transfer the enterprise menus into the main, as one big menu,

this geometry will have to be revised to reflect the main menu group name. An alternative is to

remove the menu group name prefix from the statement (menucmd "P16=+MyPop").

 

Now the fun part.

 Civil - Assign an Alias as "POP100" (mandatory), and Alias "Civil" where POP menu name.

Assign a Menu Group name of "My_Civil" (you can use the actual file name here).

 Electrical - Alias as "POP200" and "Electrical". Menu Group name is "My_Electrical".

Anything above POP16 to POP999 can be used, and will not display when editor is started.

 

Using what is shown above to insert the civil POP:

 (menucmd "P16=+My_Civil.POP100") or

 (menucmd "P16=+My_Civil.Civil")

 

Using what is shown above to insert and remove:

 (menucmd "My_Civil.POP100=+My_Electrical.POP200")

 

To remove a POP, use this:

 (menucmd "My_Electrical.POP200=-")

 

To make command line quiet, you can try to add a ^P in front of the macro:

 Macro = ^P(menucmd "My_Electrical.POP200=-")  [untested, I never had a use for this until now]

 

 

POP01_2012-10-17.png

 

For this example, this menu is an enterprise to the main ACAD.cui.

POP14 will show when the editor is started, however if I name this to POP140, it will not show and

I will use the following macro to make it display: (menucmd "P16=+JPW98-17CUSTOM.LAYERS")

 

Lastly, one can create a "home" POP that will list all your enterprise POP's. This column will show

when editor is started and then you can use the insert and remove method to display desired menu

in it's place. Go into each POP (civil, elect, etc.) and add a line either at the top or botton (next to a

separator) that will reset back to the "Home" POP.

 

Of course this is untested as I have been tinkering and studying this topic for about a week now.

See AutoCAD's Developers Guide -> Customize the User Interface -> Create Pull-Down and Shortcut

Menus for more information.

 

If you need Screen Menu help, including page swapping and layering, I'll get you there as well.

 

Scot-65

 

Scot-65
Dyslexia is a permanent physical disability that cannot be seen.
Introverts is proof that there is indeed intelligent life on this planet.
Mentor
BrentBurgess1980
Posts: 166
Registered: ‎06-16-2008
Message 5 of 6 (10,851 Views)

Re: Show/Hide Menu's in Workspace

10-18-2012 12:17 AM in reply to: scot-65

Cheers Scot-65 - That was a great help!! Managed to get it working

*Expert Elite*
scot-65
Posts: 2,210
Registered: ‎12-11-2003
Message 6 of 6 (10,831 Views)

Re: Show/Hide Menu's in Workspace

10-18-2012 04:02 PM in reply to: BrentBurgess1980

BrentBurgess1980 wrote:

Cheers Scot-65 - That was a great help!! Managed to get it working


I am in the process of creating POP's to replace the once glorious, once powerful Screen Menu.

Right now it's research, feasibility, strategy, and testing.

 

I suggest you merge all your enterprise CUI's into one.

It might prove beneficial in the long run (especially the part about having a "Home" POP).

I do not know your layering system, but you can preset the POP based on the current

layer at the time file was last saved, or look into VLAX-LDATA-GET to store the last

known menu setting, and reset when file is opened (stores your values as a dictionary

item inside the file itself).

 

LISP is a lot easier and more forgiving than C or VB.

Creating and manipulating Lists are very powerful, something I do not see in VB

(it took me a long time to get into lists, but I cannot imagine not doing anything without this).

FOREACH and REPEAT are a treat.

Look at COND - you will be pleasantly surprised.

There are others.

Downside: No advanced math functions (inverse-sin).

Basically, LISP functions were developed for the end user.

VL is for file environments both inside and outside as well as additional LISP functions

that were not originally available, due to the maturity of the software.

 

You have it easy.

Take a look at what I have. There are about 70 sub-menus that are not showing.

 

ResetScreen01.gif

 

Scot-65

Scot-65
Dyslexia is a permanent physical disability that cannot be seen.
Introverts is proof that there is indeed intelligent life on this planet.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.