mastip Posted January 2, 2023 Posted January 2, 2023 (edited) Hello, Guys this if my first topic. Hi to everybody. I am looking for a solution to create autocad menu file for all my lisp files from folder. I started from LeeMac autoloader lisp http://www.lee-mac.com/lisp/html/Autoloader.html and made some changes to create a file with rows of commands. Leemac autoloader lisp create txt file like this: (autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEAL" "STEALALL" "STEALTEMPLATE" "STEALTEMPLATES" "STEALLAST")) (autoload "C:/Lispy/LEEMAC/VPOutlineV1-3.lsp" '("VPO" "VPOL" "VPOA")) (autoload "C:/Lispy/Lispy 2020/enz.lsp" '("ENZ")) (autoload "C:/Lispy/Lispy 2020/XR253.lsp" '("XR253")) I changed lines in defun c:AutoLoader_menu function in leemac lisp (write-line (strcat "(autoload " (vl-prin1-to-string (strcat dir "/" lsp)) " '" (vl-prin1-to-string syn) ")" ) file ) to (write-line (strcat "["(vl-string-trim "()" (LM:StringSubst "" "\"" (vl-prin1-to-string syn)))"]^C^C(autoload " (vl-prin1-to-string (strcat dir "/" lsp)) " '" (vl-prin1-to-string syn) ");"(vl-string-trim "()" (LM:StringSubst "" "\"" (vl-prin1-to-string syn))) ) file ) And the results are as follows [STEAL STEALALL STEALTEMPLATE STEALTEMPLATES STEALLAST]^C^C(autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEAL" "STEALALL" "STEALTEMPLATE" "STEALTEMPLATES" "STEALLAST"));STEAL STEALALL STEALTEMPLATE STEALTEMPLATES STEALLAST [VPO VPOL VPOA]^C^C(autoload "C:/Lispy/LEEMAC/VPOutlineV1-3.lsp" '("VPO" "VPOL" "VPOA"));VPO VPOL VPOA [ENZ]^C^C(autoload "C:/Lispy/Lispy 2020/enz.lsp" '("ENZ"));ENZ [XR253]^C^C(autoload "C:/Lispy/Lispy 2020/XR253.lsp" '("XR253"));XR253 This lines from txt I am using to create menu file. I format the txt file with notepad++ My menu file example ***MENUGROUP=LISPY ***POP1 ID-01[LISPY] ID-02[->STEAL] ID-03[STEAL]^C^C(autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEAL" "STEALALL" "STEALTEMPLATE" "STEALTEMPLATES" "STEALLAST"));STEAL ID-04[STEALALL]^C^C(autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEAL" "STEALALL" "STEALTEMPLATE" "STEALTEMPLATES" "STEALLAST"));STEALALL ID-05[STEALTEMPLATE]^C^C(autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEAL" "STEALALL" "STEALTEMPLATE" "STEALTEMPLATES" "STEALLAST"));STEALTEMPLATE ID-06[STEALTEMPLATES]^C^C(autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEAL" "STEALALL" "STEALTEMPLATE" "STEALTEMPLATES" "STEALLAST"));STEALTEMPLATES ID-07[<-STEALLAST]^C^C(autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEAL" "STEALALL" "STEALTEMPLATE" "STEALTEMPLATES" "STEALLAST"));STEALLAST ID-08[->VPOUTLINE] ID-09[VPOUTLINE SINGLE]^C^C(autoload "C:/Lispy/LEEMAC/VPOutlineV1-3.lsp" '("VPO" "VPOL" "VPOA"));VPO ID-10[VPOUTLINE ALL]^C^C(autoload "C:/Lispy/LEEMAC/VPOutlineV1-3.lsp" '("VPO" "VPOL" "VPOA"));VPOL ID-11[<-VPOUTLINE ALL LAYOUTS](autoload "C:/Lispy/LEEMAC/VPOutlineV1-3.lsp" '("VPO" "VPOL" "VPOA"));VPOA ID-12[ENZ]^C^C(autoload "C:/Lispy/Lispy 2020/enz.lsp" '("ENZ"));ENZ ID-13[XR253]^C^C(autoload "C:/Lispy/Lispy 2020/XR253.lsp" '("XR253"));XR253 ***HELPSTRINGS ID-03[Steal from Drawing] ID-04[Steal All from Drawing] I wish this lisp was more automated. 1. First problem: When lisps files has more commands ("STEAL" "STEALALL" "STEALTEMPLATE" "STEALTEMPLATES" "STEALLAST"). How to create a file to print each command on a separate line [STEAL](autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEAL"));STEAL [STEALALL](autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEALALL"));STEALALL [STEALTEMPLATE](autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEALTEMPLATE"));STEALTEMPLATE [STEALTEMPLATES](autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEALTEMPLATES"));STEALTEMPLATES [STEALLAST](autoload "C:/Lispy/LEEMAC/StealV1-8.lsp" '("STEALLAST"));STEALLAST Change LM:GetSyntax function ? 2. Second problem. Automate creating a menu file - Ad ID's for popup menu ( using a loop function ?) - divide popup menu (submenu): - when there is more than 70 rows - for group off comands like STEAL" "STEALALL" "STEALTEMPLATE" "STEALTEMPLATES" "STEALLAST https://ibb.co/GsbPxBQ Autoloader_menu_by_Masti.lsp MyLisps_.mnu Edited January 2, 2023 by mastip Quote
Steven P Posted January 2, 2023 Posted January 2, 2023 Not quite what you are wanting, this is a DCL (dialogue box) LISP based menu: If you look in the top LISP in the file there is the filepaths to modify where you store your LISPs, the code runs with LH Added to the end of each of my LISPs is a small section of text with a description of the LISP - looking through the attached will give you the format I use. I did it DCL way so that I could get these descriptions. It isn't perfe4ct and some parts might not work as it is If you pick it to pieces you should find the part that grabs all the LISP names (defined by "Defun C:" ) to make the LISP - start by looking at the main DCL box, and work from the list of LISPs - should get the code you need LISPSHELP - Copy.lsp 1 Quote
tombu Posted January 2, 2023 Posted January 2, 2023 Seems more complicated than it needs to be. First I recommend keeping all your lisp in a Support File Search Path that's been added to your Trusted Folders for added security and to avoid needing to ever include paths. I use Lee Mac's Steal from Drawing many times a day and simply adding (load "StealV1-8.lsp") to my acaddoc.lsp so it never had to be loaded when I need it. Adding (or C:Steal (load "StealV1-8.lsp")) to the start of any macro including the command you want to use and the lisp file that needs to be loaded will only load the lisp if it's not already loaded as the OR test function evaluates each item until T is returned so if C:Steal is defined OR returns T and (load "StealV1-8.lsp") is not evaluated (loaded again). Many of my macros that require lisp to be loaded use this to save reloading and avoid overwriting set global variables that would be overwritten if reloaded so there's usually only a few lisp loaded in any drawing session. With others like Tharwat's enz.lsp you're using I simply use: (load "enz.lsp") enz for the macro. Quote
BIGAL Posted January 3, 2023 Posted January 3, 2023 As you mentioned 70 lines you can have pop out menus using -> and <- to close. You can pop pop menu's not limited to 1 deep. ***POP20 **CADLIB [LIBRARY] [->Stddwgs] [TRENCH]$I=COGGSTDS.TRENCH $I=* [PIPES]$I=COGGSTDS.PIPES $I=* [PITS]$I=COGGSTDS.PITS $I=* [KERBS]$I=COGGSTDS.KERBS $I=* [ROADX]$I=COGGSTDS.ROADX $I=* [PAVEMENTS]$I=COGGSTDS.PAVEMENT $I=* [MISC]$I=COGGSTDS.MISC $I=* [<-] Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.