Manuel_Kunde Posted August 4, 2021 Posted August 4, 2021 Hi all, I am trying to write a lisp that will create a DropDown list in Autocad. With the selection from the fields I want to execute different commands that I have defined before. (defun c:create_dropdown () (setq choise1 command1) (setq choise2 command2) (setq choise3 command3) (setq choise4 command4) (strcase (initget (getkword [choise1/choise2/choise3/choise4])))) ) Quote
mhupp Posted August 4, 2021 Posted August 4, 2021 Sounds like your going to need a DCL. https://autolisp-exchange.com/Tutorials/MyDialogs.htm I would like to see how it turns out. Quote
Jonathan Handojo Posted August 4, 2021 Posted August 4, 2021 Might just have to play around with the CUI and create your own tabs and ribbons. Creating a dropdown menu is a one-time setup each time you create a new one (unless your command has different names). This is an example of mine (a few of these are Lee's routines from his website): Can be structure through the user interface using CUI command or whatnot and make your own partial customization files. Can create a new command and name it to whatever your command name is, and then put a macro like this (using "^C^C_" followed by the syntax of the command to be invoked. In the example below, the name of the command being invoked is P-PUT, hence ^C^C_P-PUT) : Quote
BIGAL Posted August 5, 2021 Posted August 5, 2021 If you want a drop down menu make a custom .mnu its just a text file using Notepad, going custom is much easier than using the CUI, a POP menu can have sub menu's as well. Making a custom mnu can be edited at any time and its a simple menuload to update, we had the mnu on the server so when a user opened Autocad they always got the latest version. You can make custom tool bars as well with custom icons again using notepad. More than happy to provide examples. The other is if you want a pop DCL select use my Multi radio buttons.lsp that was written for this type of situation. Multi radio buttons.lsp 2 Quote
Manuel_Kunde Posted August 5, 2021 Author Posted August 5, 2021 6 hours ago, BIGAL said: If you want a drop down menu make a custom .mnu its just a text file using Notepad, going custom is much easier than using the CUI, a POP menu can have sub menu's as well. Making a custom mnu can be edited at any time and its a simple menuload to update, we had the mnu on the server so when a user opened Autocad they always got the latest version. You can make custom tool bars as well with custom icons again using notepad. More than happy to provide examples. The other is if you want a pop DCL select use my Multi radio buttons.lsp that was written for this type of situation. Multi radio buttons.lsp 3.38 kB · 15 downloads Do you have an example, how a .mnu file should look like? I cant find anything here. Quote
Manuel_Kunde Posted August 5, 2021 Author Posted August 5, 2021 8 hours ago, BIGAL said: If you want a drop down menu make a custom .mnu its just a text file using Notepad, going custom is much easier than using the CUI, a POP menu can have sub menu's as well. Making a custom mnu can be edited at any time and its a simple menuload to update, we had the mnu on the server so when a user opened Autocad they always got the latest version. You can make custom tool bars as well with custom icons again using notepad. More than happy to provide examples. The other is if you want a pop DCL select use my Multi radio buttons.lsp that was written for this type of situation. Multi radio buttons.lsp 3.38 kB · 16 downloads Okay, I'm now at the point where I can make a selection in AutoCAD. I want to transfer a PDF that is stored locally in a folder to another folder. About the selection I want to set a variable. Error message: stract Incorrect argument type stringp nil (The stract path at the end still works, I defined it before). (defun c:pdftransfer (/ ) (initget "monday.pdf tuesday.pdf" ) (setq Request (getkword "Choose your pdf [monday.pdf/ tuesday.pdf ] ") ) (vl-file-copy (strcat "\\\\netlan.de\root\\de\\pdf\\" Request) (strcat Pathone Contact Pathtwo Order Paththree Request) ) ) Quote
Jonathan Handojo Posted August 5, 2021 Posted August 5, 2021 2 hours ago, Manuel_Kunde said: Okay, I'm now at the point where I can make a selection in AutoCAD. I want to transfer a PDF that is stored locally in a folder to another folder. About the selection I want to set a variable. Error message: stract Incorrect argument type stringp nil (The stract path at the end still works, I defined it before). (defun c:pdftransfer (/ ) (initget "monday.pdf tuesday.pdf" ) (setq Request (getkword "Choose your pdf [monday.pdf/ tuesday.pdf ] ") ) (vl-file-copy (strcat "\\\\netlan.de\root\\de\\pdf\\" Request) (strcat Pathone Contact Pathtwo Order Paththree Request) ) ) I'd presume it would have to do with the capitalisation of the initget prompts... maybe try "Monday.pdf Tuesday.pdf" instead. The other thing would be the fact that when no bitcode is set for the initget, pressing Enter on getkword actually returns nil. So your other option would have to go the long way and do something like: (setq Request (cond ( (getkword (strcat "\nChoose your pdf [Monday.pdf/Tuesday.pdf] <" (cond (Request) ("Monday.pdf")) ">: " ) ) ) (Request) ("Monday.pdf") ) ) Quote
Stefan BMR Posted August 5, 2021 Posted August 5, 2021 22 hours ago, Manuel_Kunde said: Hi all, I am trying to write a lisp that will create a DropDown list in Autocad. With the selection from the fields I want to execute different commands that I have defined before. (defun c:create_dropdown () (setq choise1 command1) (setq choise2 command2) (setq choise3 command3) (setq choise4 command4) (strcase (initget (getkword [choise1/choise2/choise3/choise4])))) ) The easiest way is to use DosLib Once installed and loaded, use dos_popupmenu function. (setq lst '("Moday.pdf" "Tuesday.pdf")) (if (setq n (dos_popupmenu lst)) (setq request (nth n lst)) ) Quote
BIGAL Posted August 6, 2021 Posted August 6, 2021 (edited) Stefan only problem is must have Doslib loaded. But same as Multi radio must load 1st. Not every one has doslib downloaded thats why I try to not use it. Adds to the complexity of getting user to download and install. Have enough problems getting end users to run provided code. (load "DOSLib23x64.arx") (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not but)(setq but 1)) (setq request (strcat (ah:butts but "V" '("Choose day " "Monday" "Tuesday" "Wednesday" )) ".pdf")) But yes Doslib has some great functions 1 do use is progress bar. Edited August 6, 2021 by BIGAL 1 Quote
Manuel_Kunde Posted August 6, 2021 Author Posted August 6, 2021 3 hours ago, BIGAL said: Stefan only problem is must have Doslib loaded. But same as Multi radio must load 1st. Not every one has doslib downloaded thats why I try to not use it. Adds to the complexity of getting user to download and install. Have enough problems getting end users to run provided code. (load "DOSLib23x64.arx") (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not but)(setq but 1)) (setq request (strcat (ah:butts but "V" '("Choose day " "Monday" "Tuesday" "Wednesday" )) ".pdf")) But yes Doslib has some great functions 1 do use is progress bar. Very good work, the Radio-lisp works perfectly! Thanks so far. Is there a way that I can first confirm the selection with the ok Button, and then the window closes? Currently the window closes when I select something. Quote
tombu Posted August 6, 2021 Posted August 6, 2021 On 8/5/2021 at 5:17 AM, Manuel_Kunde said: Okay, I'm now at the point where I can make a selection in AutoCAD. I want to transfer a PDF that is stored locally in a folder to another folder. About the selection I want to set a variable. Error message: stract Incorrect argument type stringp nil (The stract path at the end still works, I defined it before). Keyword Specifications https://help.autodesk.com/view/ACD/2022/ENU/?guid=GUID-9ED8841B-5C1D-4B3F-9F3B-84A4408A6BBF The string argument is interpreted according to the following rules: Each keyword is separated from the following keyword by one or more spaces. For example, "Width Height Depth" defines three keywords. Each keyword can contain only letters, numbers, and hyphens (-). You're trying to use filenames with a period in them. Try using (initget "monday tuesday") (setq Request (getkword "Choose your pdf [monday/tuesday] ") Request (strcat Request ".pdf") 1 Quote
BIGAL Posted August 7, 2021 Posted August 7, 2021 When I wrote the code I wanted minimum picks hence closes on pick, but easy fix. ;(action_tile k (strcat "(setq but " (rtos x 2 0) ")" "(done_dialog)")) (action_tile k (strcat "(setq but " (rtos x 2 0) ")")) (if (= ahdef x)(set_tile k "1")) (setq x (+ x 1)) ) ;(action_tile "accept" (strcat "(setq but " (rtos ahdef 2 0) ")" "(done_dialog)")) (action_tile "accept" "(done_dialog)") Quote
Manuel_Kunde Posted August 19, 2021 Author Posted August 19, 2021 (edited) On 8/6/2021 at 1:55 PM, tombu said: Keyword Specifications https://help.autodesk.com/view/ACD/2022/ENU/?guid=GUID-9ED8841B-5C1D-4B3F-9F3B-84A4408A6BBF The string argument is interpreted according to the following rules: Each keyword is separated from the following keyword by one or more spaces. For example, "Width Height Depth" defines three keywords. Each keyword can contain only letters, numbers, and hyphens (-). You're trying to use filenames with a period in them. Try using (initget "monday tuesday") (setq Request (getkword "Choose your pdf [monday/tuesday] ") Request (strcat Request ".pdf") This works very simple. Edited August 19, 2021 by Manuel_Kunde 1 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.