Custom POP menus

Custom POP menus

id_11
Advocate Advocate
1,124 Views
10 Replies
Message 1 of 11

Custom POP menus

id_11
Advocate
Advocate

I have custom menus which insert structural steel shapes into AutoCAD. There are 2 menus, one for normal blocks (POP102) and the other for dynamic blocks (POP112).


The process is:

- Setup 2 folders, one for each POP menu.

- Prepare an AutoCAD file for each structural section, and save in the same directory.

- Write menu files (MNU) as per code below (abbreviated version).

- Load each menu file with command CUILOAD, browse for MNU file and load.

- AutoCAD automatically process the MNU file (which is legacy I think) and turns it into a CUIX file. It's saved in the same directory.

- In Tools, Options, Files tab, Support File Search Path ... add the 2 directories for each POP menu.


This works except for the fact that AutoCAD files have the same filename in each POP menu.

So if I want to insert a dynamic version of a 530UB82 from POP112, it will actually insert the normal version from POP102.


Is there a way to resolve if the filenames are the same?

 

***MENUGROUP=STRUCTURAL_STEEL
***POP102
**CTOPopSTRUCTURAL_STEEL

[Structural Steel]

[->UB]
   [530UB82]^C^C(BlockInsert "UniversalBeams_530UB82.0");scale;1;
   [<-530UB92]^C^C(BlockInsert "UniversalBeams_530UB92.4");scale;1;
[--]

 

***MENUGROUP=STRUCTURAL_STEEL_DYNAMIC
***POP112
**CTOPopSTRUCTURAL_STEEL_DYNAMIC

[Structural Steel (Dynamic)]

[->UB]
   [530UB82]^C^C(BlockInsert "UniversalBeams_530UB82.0");scale;1;
   [<-530UB92]^C^C(BlockInsert "UniversalBeams_530UB92.4");scale;1;
[--]

 

0 Likes
1,125 Views
10 Replies
Replies (10)
Message 2 of 11

Moshe-A
Mentor
Mentor

@id_11  hi,

 

Your 2 popups menu have the exact macro. how would you expect AutoCAD knows how to differ between them?!

the second menu has this:

[Structural Steel (Dynamic)]

but this is only a text (not macro code) and autocad skip it

 

According to Support Files Search Path order AutoCAD brings in the block (wblock) it finds first.

to resolved this, you have to use different block names. be aware that the insert is done by lisp function called (BlockInsert).

 

Moshe

 

0 Likes
Message 3 of 11

pendean
Community Legend
Community Legend

Exact same 100% identical macros are being used in both menus, so you'll get the same exact blocks in each one of them, with no variation.  Looks like someone forget to change the blocks names being inserted for one of the POP menus

 

pendean_0-1612796502595.png

 

0 Likes
Message 4 of 11

id_11
Advocate
Advocate

pandean, thanks for responding, but did you read the original post???

It mentions the filenames are the same. The headings in each MNU file are different, so you will get two menu files.

It is a legacy method, but I want to keep using it. In older versions of AutoCAD, menu files were loaded with a script which had the target directory. However I cannot seem to load more than 1 or 2 menus at best.

The script below would load one menu file. If another script is run for another menu file, it may or may not load. A third script usually gets rid of the previous one or two menus. It's unstable, maybe because it's a legacy method.

 

The procedure explained in the original post works, except for the issue with the identical filenames.

But it doesn't look like this can be resolved.

 

By the way, with the script below:

1. I don't know if this is partially equivalent to the method in the original post.

2. I can't load both menu files at the same time to test whether the issue (with the same filenames) would still be there.

 

(if (and (not (findfile "STRUCTURAL_STEEL_DYNAMIC.mnu"))
(findfile "C:\\POP112 Structural Steel (D)\\STRUCTURAL_STEEL_DYNAMIC.mnu"))
(setenv "ACAD" (strcat (getenv "ACAD") "C:\\POP112 Structural Steel (D)")))
(command "._MENULOAD" "STRUCTURAL_STEEL_DYNAMIC.mnu")
(menucmd "P112=+STRUCTURAL_STEEL_DYNAMIC.CTOPopSTRUCTURAL_STEEL_DYNAMIC")

 

0 Likes
Message 5 of 11

id_11
Advocate
Advocate
Sorry I didn't see this, thanks for responding.
0 Likes
Message 6 of 11

rgrainer
Collaborator
Collaborator

What determines which block type gets inserted? is the type of job one does, is it a user preference or what?
Are both menus used in an editing session or does the user determine if they will be inserting standard or dynamic blocks during that session while in the dwg? Or are they switching the block types between standard and dynamic as they work?
Instead on mnu each time, why not use and load the cuix that gets created the first time?
I think you also need to look at the order that you load your menus, last one loaded wins.

0 Likes
Message 7 of 11

id_11
Advocate
Advocate
 

Please see below.

 

What determines which block type gets inserted?

This is situation dependent.


Are both menus used ...

Yes.

 

... are they switching the block types between standard and dynamic ...

No.


Instead on mnu each time, why not use and load the cuix that gets created the first time?
The cuix file is automatically created from the mnu file. I don't want to swap out the mnu method as my knowledge is not great with this. Any coding that you see here was taken from a textbook.

The issue though is with duplicate file names.

0 Likes
Message 8 of 11

rgrainer
Collaborator
Collaborator

I understand that both menus are used, but if the user needs to do a particular job they have to decide "will i use standard blocks or dynamic ones" and then they determine that dynamic blocks are needed, then does that mean that the standard blocks won't be used from that point on and therefore that menu doesn't need to be loaded?

0 Likes
Message 9 of 11

id_11
Advocate
Advocate

Yes I do understand what you mean, I thought about that too.

If it's not possible, then I'll just have to either change file names or unload/reload menus as suggested.

0 Likes
Message 10 of 11

rgrainer
Collaborator
Collaborator

It can be easily setup to ask the user if they want to use Standard or Dynamic blocks and then load the proper cuix/mnu after they answer.  
I do pop menus all day, no ribbons, minimal toolbars, if you have any more questions just let me know.

0 Likes
Message 11 of 11

id_11
Advocate
Advocate

OK thanks for advising.

0 Likes