Nikon Posted September 21 Posted September 21 (edited) Is it possible in a multifunctional lisp to select the necessary command in the command line with the letters highlighted? d (getkword "breakAll, [breakwoBjects/breakObject/breakWith/breakTouching/breakSelected] <A>: ") If possible, where do I need to insert part of the code to make it work... I have doubts and questions about this part of the code... thanks... For example, for lisp breakall (Author: Copyright© 2006,2007 Charles Alan Butler) https://www.cadtutor.net/forum/topic/91302-break-lines-with-others-lines-help/ (progn (initget "breakAll breakwoBjects breakObject breakWith breakTouching breakSelected") (setq b 0 c (sslength a) d (getkword "breakAll, [breakwoBjects/breakObject/breakWith/breakTouching/breakSelected] <A>: ") ) (while (< b c) (setq e (entget (ssname a b)) f (cdr (setq g (assoc 1 e))) ) (cond ((= d "breakAll") (setq f (strcat "(???)"))) ((= d "breakwoBjects") (setq f (strcat "(???)"))) ((= d "breakObject") (setq f (strcat "(???)"))) ((= d "breakWith") (setq f (strcat "(???)"))) ((= d "breakTouching") (setq f (strcat "(???)"))) ((= d "breakSelected") (setq f (strcat "(???)"))) ? ? ? ? ) (setq e (subst (cons 1 f) g e)) (entmod e) (setq b (1+ b)) ) ) (princ "\nNo texts selected") Edited September 21 by Nikon Quote
mhupp Posted September 21 Posted September 21 kword is smart enough to know the options you wanted you just have type the letter that are only in that option that were set in the initget. For example this is how I used kword with a default option so the user can just hit enter if they wanted to pick No. but if they wanted the "yes" they could have type YES, Y, or even just E or S it would have picked the yes option since those letters aren't in No. (initget "Yes No") (setq rep (cond ((getkword "\nSave Drawing? [Yes/<No>]: ")) ( "No") ) ) With that many options and similar spellings it might be better to go the @BIGAL route and use a multi radio buttons. https://www.cadtutor.net/forum/topic/11657-options-within-a-lisp/?do=findComment&comment=633559 if your dead set on wanting to use kword just have multiple unique options. seems to clunky and hard to read imo. (initget "breakAll breakwoBjects breakObject breakWith breakTouching breakSelected B O W") (setq option (getkword "\nChoose an option [breakAll/breakwo[B]jects/break[O]bject/break[W]ith/breakTouching/breakSelected <A>]: ")) (cond ((= option "breakAll")) (setq f )) ;doesn't need a option since All is unique ((or (= option "B") (= option "breakwoBjects")) setq f)) ;if only B is type this option will be chosen ((or (= option "O") (= option "breakObject")) (setq f )) ((or (= option "W") (= option "breakWith")) (setq f )) ((= option "breakTouching")) (setq f )) ((= option "breakSelected")) (setq f )) (T (princ "\nInvalid option selected")) ) (princ) ) All that said id just use Cab's lisp. 1 Quote
Nikon Posted September 21 Author Posted September 21 5 minutes ago, mhupp said: (setq option (getkword "\nChoose an option [breakAll/breakwo[B]jects/break[O]bject/break[W]ith/breakTouching/breakSelected <A>]: ")) Thanks @mhupp, I'll try... I was interested to find out the solution via getkword... Quote
Nikon Posted September 21 Author Posted September 21 (edited) 4 hours ago, mhupp said: With that many options and similar spellings it might be better to go the @BIGAL route and use a multi radio buttons. I am adding these lines to breakAll.lsp (setq ans (ah:butts 1 "V" '("BreakwObjects BreakObject BreakWith BreakTouching BreakSelected" "BreakwObjects" "BreakObject" "BreakWith" "BreakTouching" "BreakSelected" ))) (setq ans (atoi (ah:butts 1 "V" '("Please choose " "BreakwObjects" "BreakObject" "BreakWith" "BreakTouching" "BreakSelected"" )))) and I get such a window with selection options: But for some reason, only the basic command breakAll works? Multi radio buttons - it's unique! universal! A fantastic program! Thanks a lot to the author Charles Alan Butler! Edited September 21 by Nikon Quote
mhupp Posted September 21 Posted September 21 Their are several different commands in CAB's lisp. you only need one of the ans (defun C:foo () (if (not AH:Butts)(load "Multi radio buttons.lsp")) (setq ans (ah:butts 1 "V" '("Choose Break Option" "BreakAll" "BreakwObjects" "BreakObject" "BreakWith" "BreakTouching" "BreakSelected"))) (cond ((or (= ans "BreakAll") (= ans nil)) ;change (= ans nil) locaiton to where you want the default option to be (c:breakall) ) ((= ans "BreakwObjects") (c:breakwobjects) ) ((= ans "BreakObject") (c:BreakObject) ) ((= ans "BreakWith") (c:BreakWith) ) ((= ans "BreakTouching") (c:BreakTouching) ) ((= ans "BreakSelected") (c:BreakSelected) ) ) ) 1 Quote
BIGAL Posted September 22 Posted September 22 (edited) Thanks Mhupp. A hidden option is that a variable "but" is returned the button chosen, so can make the cond a little simpler ((= but 5)(c:BreakSelected)) Another hint, (ah:butts 1 the number 1 is the first button so you can remember the button last selected and when ran again it will show that one. (if (= butnum nil)(setq butnum 1)) (setq ans (ah:butts butnum "V" '("Choose Break Option" "BreakAll" "BreakwObjects" "BreakObject" "BreakWith" "BreakTouching" "BreakSelected"))) (setq butnum but) Edited September 22 by BIGAL 1 Quote
Nikon Posted September 22 Author Posted September 22 (edited) @mhupp and @BIGAL thanks, I apologize for my misunderstanding. I'm doing something wrong, I'm adding this to the code, but I get an error message. error: no function definition: C:BREAKWOBJECTS or error: incorrectly formed list at the entrance, if I add this - (defun C:foo ()... I will give 2 attempts BreakAll-Multi1.lsp BreakAll-Multi2.lsp Edited September 22 by Nikon Quote
mhupp Posted September 22 Posted September 22 Yes it needs to be wrapped. change foo to what you want to type to pop up the menu asking type of break. ;(defun C:foo () ; ??? is this line needed? error: incorrectly formed list at the entrance You also need the AH:Butts code as well. 1 Quote
BIGAL Posted September 23 Posted September 23 You don't need to paste the code for multi radio buttons into your code but you do need to pre load the Multi radio buttons.lsp. (if (not AH:Butts)(load "Multi Radio buttons.lsp")) make sure you have multi radio buttons saved in a support path or change the (load ... to include the full path of where multi radio buttons is saved, the same with CABS program you can use the same (if (not break_with)(load "Breakall")) so dont need program inside your code. I would do these 2 load checks at very start of code. 1 Quote
tombu Posted September 23 Posted September 23 On 9/21/2024 at 3:19 AM, Nikon said: Is it possible in a multifunctional lisp to select the necessary command in the command line with the letters highlighted? Lee Mac has a few examples at: https://www.lee-mac.com/promptwithdefault.html That's how I use it in most of my code. 1 Quote
Nikon Posted September 24 Author Posted September 24 10 hours ago, tombu said: Lee Mac has a few examples at: https://www.lee-mac.com/promptwithdefault.html That's how I use it in most of my code. Thanks @tombu, it works. (defun c:breakall (/ cmd ss) (initget "breakAll breakObject breakwoBjects breakWith breakTouching breakSelected") (setq ans (cond ((getkword "\nChoose [breakAll/breakObject/breakwoBjects/breakWith/breakTouching/breakSelected] <breakAll>: ")) ("breakAll"))) 1 Quote
BIGAL Posted September 24 Posted September 24 When you use a defun need it's full name eg (C:breakall) Or (command "breakall") A simple defun may not have the c : (Mybreak) 1 Quote
Nikon Posted September 24 Author Posted September 24 (edited) 2 hours ago, BIGAL said: When you use a defun need it's full name eg (C:breakall) Or (command "breakall") (defun c:breakall (/ cmd ss) ; added for Multi Radio buttons (setq ans (list "Please choose" "breakall" "BreakObject" "BreakwObjects" "BreakWith" "BreakTouching" "BreakSelected")) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (setq anssz (atof (ah:butts 1 "v" ans))) I can't add "Multi Radio buttons" to the program "breakall" ("Multi Radio buttons" is downloaded and used in other programs). A dialog box appears, but only one "breakall" command is executed... For the "BreakObject" command, a request is output for the "break all" command: Select All objects to break & press enter: but the program has such a request: Select single object to break: Edited September 24 by Nikon Quote
BIGAL Posted September 26 Posted September 26 (edited) I take a different approach to this task. I autoload multi radio buttons and Breakall.lsp then do the cond and call the correct sub defun. (defun c:wow ( / ans) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not break_with)(load "Breakall.lsp")) (setq ans (atof (ah:butts 1 "v" (list "Please choose" "Breakall" "BreakObject" "BreakwObjects" "BreakWith" "BreakTouching" "BreakSelected")))) (cond ((= ans "BreakAll")(c:breakall)) ((= ans "BreakwObjects")(c:breakwobjects)) ((= ans "BreakObject")(c:BreakObject)) ((= ans "BreakWith")(c:BreakWith)) ((= ans "BreakTouching")(c:BreakTouching)) ((= ans "BreakSelected")(c:BreakSelected)) ) (princ) ) (c:wow) Edited September 27 by BIGAL 1 Quote
Nikon Posted September 26 Author Posted September 26 (edited) 1 hour ago, BIGAL said: I take a different approach to this task. I autoload multi radio buttons and Breakall.lsp then do the cond and call the correct sub defun. I call the wow command... A dialog box with a selection appears, but I can't select a command, the window disappears, I don't even have time to click OK. Do I need changes in the Breakall code? Edited September 26 by Nikon Quote
BIGAL Posted September 27 Posted September 27 (edited) Changed code above a fraction. Ok copy 1 line at a time. and paste to command line. (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not break_with)(load "Breakall.lsp")) If you get an error in the load line then its saying it can not find lisp file. So add the full path to the lisp file make sure you use \\ in directory names. (setq ans (atof (ah:butts 1 "v" (list "Please choose" "Breakall" "BreakObject" "BreakwObjects" "BreakWith" "BreakTouching" "BreakSelected")))) The command line should show the choice, eg "Breakall" yes there was a typo need capital "B" name must be exact match upper and lowercase. Edited September 27 by BIGAL 1 Quote
Nikon Posted September 27 Author Posted September 27 (edited) 1 hour ago, BIGAL said: If you get an error in the load line then its saying it can not find lisp file. So add the full path to the lisp file make sure you use \\ in directory names. @BIGAL thanks! if paste to command line Command: (load "Multi Radio buttons.lsp") AH:BUTTS Command:(load "Breakall.lsp") Break Routines Loaded, Enter BreakAll, BreakEnt, or BreakWith to run.C:BREAKSELECTED if you add (if (not AH:Butts) and paste to the command line Command: (if (not AH:Butts)(load "Multi Radio buttons.lsp")) nil Command: (if (not AH:Butts)(load "Multi Radio buttons.lsp")) nil Command: (if (not break_with)(load "Breakall.lsp")) nil So the problem is not in the file path? Works well for me Multi Radio buttons.lsp in the code from the theme https://www.cadtutor.net/forum/topic/78583-single-pline-to-multi-line-with-radiusstart-and-end-close/ (defun c:test ( / bar barsz ent ent1 ent2 ent3 ent4 off1 off2 st1 st2 end1 end2 obj) (setq bar (list "Please choose" "6" "8" "10" "12" "14" "16" "18" "20" "22" "25" "28" "32" "36" "40")) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (setq barsz (atof (ah:butts 1 "v" bar))) .... ............ Edited September 27 by Nikon Quote
BIGAL Posted September 28 Posted September 28 (if (not AH:Butts) this checks does the function AH:butts exist if not then load it, so if you did (load "Multi Radio buttons.lsp") then try again as the program has already been loaded it will not load it again hence the nil. I autoload a couple of multi lisp's so I never see the "AH:butts". 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.