Aditya Bagaskara Posted February 21, 2023 Posted February 21, 2023 There's one function in AutoLISP that resides on 'get' functions that I don't understand. How exactly do you use getkword and initget? (usually they are used together) And how do you make a command that can change option (like when you press down arrow and you see bunch of options like arc, halfwidth etc. after inserting Polyline command) with getkword and initget? Quote
Tharwat Posted February 21, 2023 Posted February 21, 2023 You can explore the help document which covers all other get functions as well. https://help.autodesk.com/view/ACD/2023/ENU/?guid=GUID-9ED8841B-5C1D-4B3F-9F3B-84A4408A6BBF Quote
Tharwat Posted February 21, 2023 Posted February 21, 2023 Here is an example that I posted in this forum a few hours ago. 1 Quote
tombu Posted February 21, 2023 Posted February 21, 2023 While not covered in AutoCAD Help for getkword (AutoLISP) use the [...] brackets instead of (...) like Tharwat does in his code example which makes selection options easier. Quote
Steven P Posted February 21, 2023 Posted February 21, 2023 (edited) Yes generally initget is defined before getkword: (initget "Option1 Option2")) ; note here the options are only single words, option 1 is 'option' and '1' (setq x (getkword "Enter option (Option1 or Option2) ")) In the getkword you can highlight the shortcuts with square brackets and capital letters for the shortcut.: (initget 1 "Yes No") (setq x (getkword "Are you sure? [Yes/No] ")) Initget will limit the options you can use in getkword. Getkword is like getstring, or getreal but limited to what initget has listed. You don't need to list all the options in getkword: (initget "Option1 Option2 HiddenOption")) ; note here the options are only single words, option 1 is 'option' and '1' (setq x (getkword "Enter option (Option1 or Option2) ")) Generally I would use initget in the line just before getkword. For the other art of your question I learnt alot after posting this, see Lee Macs last code: Edited February 21, 2023 by Steven P Quote
Steven P Posted February 21, 2023 Posted February 21, 2023 (edited) And here is a little function example for you: (defun MyTxtSelOptions ( / acount TxtLst msg MyTxt MyNum) (setvar "errno" 0) (setq acount 1) (setq TxtLst (list)) (while (/= 52 (getvar "errno")) (initget "Opt1 Opt2 Opt3 Exit") ; Opt for alphanumeric options (setq msg (strcat "\nSelect Text " (rtos acount) ", or enter options: [Opt1/oPt2/opT3/Exit]: ")) (setq MyTxt (nentsel msg) ) (cond ((= 'str (type MyTxt)) ; text entered (setq TxtLst (append TxtLst (list MyTxt))) (princ MyTxt)(princ " Option Chosen") ) ; end cond ((= 'list (type MyTxt)) ; entity selected (setq MyTxt (car MyTxt)) (if (wcmatch (cdr (assoc 0 (entget MyTxt)) ) "*TEXT") ; filter for entity type (progn (setq TxtLst (append TxtLst (list MyTxt))) (setq acount (+ acount 1)) (princ MyTxt) ) (progn ; nothing selected or escaped (princ "No! Text not selected") ) ) ; end if ) ; end cond (t (setvar "errno" 52) ) ; end cond ) ; end conds ) ; end while TxtLst ) Edited February 21, 2023 by Steven P Quote
BIGAL Posted February 21, 2023 Posted February 21, 2023 I have replaced using initget with Multi radio buttons.lsp its similar in that it uses 2 lines of code. Look at examples in program. Multi radio buttons.lsp 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.