AutoCAD Menus for specific environments.

AutoCAD Menus for specific environments.

CSM_MAI
Advocate Advocate
1,309 Views
9 Replies
Message 1 of 10

AutoCAD Menus for specific environments.

CSM_MAI
Advocate
Advocate

Is there a way to have only certain menus show up in AutoCAD without having a different workspace? For example, when utilizing a server based AutoCAD support file setup for multiple offices, Is it possible for AutoCAD to startup,  look for i.e. computername, subnet, etc. and then based on what it finds, load a custom pull-down menu designated for that office? Correct me if i'm wrong, but I don't believe you can load a .cuix file during startup? I have the info to pull the computername or subnet, but I don't know what is involved in potentially loading a custom menu based on what it finds. Thanks for any info. 

 

Chris

0 Likes
Accepted solutions (1)
1,310 Views
9 Replies
Replies (9)
Message 2 of 10

Shneuph
Collaborator
Collaborator

This is pretty much pseudocode; by no means a solution..  But if I were going to attempt what you want I it's how I would start..  I'm not certain if you will be able to do this in the ACAD.lsp at startup either.

 

 

(vl-load-com)
(setq tlv-mg (vla-get-menugroups (vlax-get-acad-object)))
(cond
  (;cond office a
   (= subnet? "office A");office identifier
   (if (setq Unloadthis (vla-item tlv-mg "Menu Name I don't want"))
     (vla-unload unloadthis)
     );if
   (if (not (vla-item tlv-mg "Menu Name I want Loaded"))
     (vla-load "C:\\Path\\Menufile.cuix")
     );if
   );cond A
  (= subnet? "office B");office identifier
   (if (setq Unloadthis (vla-item tlv-mg "Menu Name I don't want"))
     (vla-unload unloadthis)
     );if
   (if (not (vla-item tlv-mg "Menu Name I want Loaded"))
     (vla-load "C:\\Path\\Menufile.cuix")
     );if
   );cond B
  );cond

 

I used this website for reference:  http://entercad.ru/acadauto.en/  It may come in handy.  The blocks are all links and if you click them you'll get more detailed information on the objects and how to use visual lisp to manipulate them.

MenuGroups.jpg

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 3 of 10

scot-65
Advisor
Advisor
>> load a custom pull-down menu

It is possible to swap POP's based on a discipline however, one might
need to set a flag in a place such as SETCFG/GETCFG to know which POP
to display. I'm not sure computer name or subnet is the way to go - a list
will have to be maintained. Perhaps set up a DCL with Radio Buttons and
let the user set upon first time use?

To swap POP's, one must know both the Alias and Element ID of the POP's
in order for the new POP to replace an existing POP. Remember, POP
positions and count will vary between workstations and not set to a fixed
number or order. The Alias is used to do the swapping and the Element ID
is used to get the position of the POP to be replaced.

(can you tell I have encountered this?)

If not SETCFG, perhaps set up a Pull-Down (with keyboard support) that lists
all custom POP's and let the user choose which one to set [is how we do it here].

A few versions back Autodesk gave all of us a heads up that POP swapping
will no longer be supported (an API thing?). For now we are swapping until
that dreaded day...

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

Message 4 of 10

CSM_MAI
Advocate
Advocate

ShneuphMy only concern with loading and unloading a menu, is that the workspace designates what menus will show up. So if one is unloaded, the one that is reloaded may not necessarily show up because it's not listed in the workspace. Would I need to have all of the different menus need to loaded into the workspace but only the chosen one will show up and the rest "unresolved"?

 

also,  scot-65 I had thought about the ratio buttons, but this is for plotting, and I want to limit the amount of buttons the User has to click before they plot. The pull-down menu seems to be a little quicker in my opinion than a dialog box poping up. click the drop down, and then the preset papersize to their plotter/printer."to swap POP's, one must know both the Alias and Element ID of the POP's in order for the new POP to replace an existing POP." Could you explain what POP is? I am not familiar with the term POP.

 

Thanks for the info.

0 Likes
Message 5 of 10

CSM_MAI
Advocate
Advocate

Is it possible to change the filepath to a partially loaded customization file via lisp? something with (findfile "xxxxx.cuix") and set a new file path?

0 Likes
Message 6 of 10

Shneuph
Collaborator
Collaborator

@CSM_MAI wrote:

"...So if one is unloaded, the one that is reloaded may not necessarily show up because it's not listed in the workspace."


AFAIK, workspace settings control the visibility of items like toolbar objects (Which have a "visible" property that can be set with your lisp).  PopupMenus have methods called InsertInMenuBar and RemoveFromMenuBar; so after you load your MenuGroup from the file you could control how its items are shown in the menubar as well.

 

If you do this with lisp and the workspaces are set to automatically save it may go pretty smoothly.  You'll probably get toolbars popping into strange places at first though.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 7 of 10

scot-65
Advisor
Advisor
My hint on the dialog box is to set the pull-down (POP) the first
time a workstation executes AutoCAD. Use that dialog to store
the discipline setting and forget it.

Did I misunderstand your original post?
I understood what you wrote as your organization has several
divisions where each division has a specific pull-down. You want
the ability to set the pull-down according to the division's
discipline and not be able to see any other division's pull-down?

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 8 of 10

CSM_MAI
Advocate
Advocate

I misunderstood your comment. Yes, that is exactly what I am looking for. Like you said, have ratio buttons for each office, and depending on which button is selected, it will then populate the appropriate menu. I am familiar with DCL, Ratio buttons, lists and such, but I don't have any idea on how to make it work for menus. Like you said, the First time AutoCAD is ran, it will pop up a DCL box, Choose the office, then that will change the appropriate menu settings. If you can provide any information on the last part I would be most appreciative. If the DCL would run a common lisp, that would probably be better for me as I am not versed in  .net or visual lisp. Thanks for your help. 

 

 

http://help.autodesk.com/view/ACDLT/2016/ENU/?guid=GUID-2BA35BC5-2E52-4A10-8D67-A71EE449ED88

 

I think I could probably use some of the information in the link above. 

0 Likes
Message 9 of 10

scot-65
Advisor
Advisor
Accepted solution

Ahhh... that link. I think I wore down those words by endless re-reading.

 

The following spoiler is how to find and set the POP. The argument is the

new Alias name. The list you need to build is your "custom" Element ID's

which can be found in the fourth pane, inside the CUI. Highlight the

desired pull-down in the first pane to activate.

 

Spoiler
;;
;;==== FUNCTION Set Dwg Mode Menu Bar POP (also removes stray DM POP's) =====
;; Argument is [POP alias name].
(defun MENUBAR-POP-SWAP ( a / b f n ELID )
 (setq b nil)
 (vl-catch-all-apply (function (lambda ()
  (vlax-for menu (vla-get-menubar (vlax-get-acad-object))
   (setq b (cons (substr (vla-get-TagString menu) 9) b)) ;"Element ID"
 ))))
 ;*** For each "Drawing Mode" POP to be added, add the "Element ID" to this list. ***
 (setq ELID (list "292C2" "11001" "B185C" "2225A" "9789C" "84D56" "91EE8" "126F2"
          "E6690" "98056" "4A7AC" "21D28" "4FF39" "FED66" "EEB50" "B347F" "72FFA"))
 (setq n 1 f nil)
 (foreach x (reverse b)
  (if (member x ELID)
   (if (not f)
    (progn (menucmd (strcat "P" (itoa n) "=" a))(setq f n)) ;swap menu
    (progn (menucmd (strcat "P" (itoa f) "=-"))(setq f (1- f))) ;remove stray
   );if
  );if
  (setq n (1+ n))
  (if f (setq f (1+ f)))
 );foreach
 (if (not f) (menucmd (strcat "P" (itoa n) "=+" a))) ;display if none found
 (setq b nil f nil n nil ELID nil)
);end MENUBAR-POP-SWAP
;;

 

This also will remove additional stray pull-downs and add the pull-down if there is no

matching pull-downs from inside the element ID list.

 

The reason I am giving this away is that I had help from other

members of this community develop this block of code.

 

As far as the DCL, it should be pretty basic and straight forward. I'll help you along with that as well.

Hint: Assign allow_accept to each button as well as having the ok_cancel;

 

Hope this helps.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

Message 10 of 10

CSM_MAI
Advocate
Advocate

You have certainly guided me in the right direction. Thanks again for this information. 

0 Likes