Dahzee Posted April 28, 2022 Posted April 28, 2022 I found this routine online without the Authors Header, so I can't tell you who created this in the first place (but thank you none the less). I tweaked a couple of things within my limited lisp knowledge to suit me but have now run out of talent! I would like the routine to default to Yes when asked if I want to turn it into a Polyline, so I can just press Enter and away it goes. But it doesn't seem to be as simple as just changing the No to Yes, I still have to press Y for it to create the polyline. Could someone show me what I need to change so I can understand how it works? Many Thanks in advance. (defun c:CFR (/ e1 e2 lst lst2 ss) (setvar 'filletrad (cond ((getdist (strcat "\nSpecify fillet radius <" (rtos (setvar 'filletrad 0.0)) ">: "))) ((getvar 'filletrad)) ) ;_ cond ) ;_ setvar (while (and (or lst (and (setq e1 (entsel "\nSelect Entity: ")) (or (vl-position (cdr (assoc 0 (entget (car e1)))) '("ARC" "LINE" "LWPOLYLINE")) (alert "Invalid object!") ) ;_ or (setq lst (cons e1 lst)) ) ;_ and ) ;_ or (setq e2 (entsel "\nSelect next entity: ")) (or (vl-position (cdr (assoc 0 (entget (car e2)))) '("ARC" "LINE" "LWPOLYLINE")) (alert "Invalid object!") ) ;_ or (setq lst (cons e2 lst)) (vl-cmdf "_.fillet" (cadr lst) (car lst)) (or (zerop (getvar 'filletrad)) (setq lst2 (cons (list (entlast)) lst2))) ) ;_ and ) ;_ while (initget 0 "Yes No") (and (eq "Yes" (getkword "\nConvert to LWPolyline? [Yes/No] <No>: ")) (setq ss (ssadd)) (foreach x (append lst lst2) (setq ss (ssadd (car x) ss))) (if (zerop (getvar 'peditaccept)) (vl-cmdf "_.pedit" "_m" ss "" "_y" "_j" "" "") (vl-cmdf "_.pedit" "_m" ss "" "_j" "" "") ) ;_ if ) ;_ and (princ) ) ;_ defun Quote
exceed Posted April 28, 2022 Posted April 28, 2022 (edited) (defun c:CFR (/ e1 e2 lst lst2 ss answer) (setvar 'filletrad (cond ((getdist (strcat "\nSpecify fillet radius <" (rtos (setvar 'filletrad 0.0)) ">: "))) ((getvar 'filletrad)) ) ;_ cond ) ;_ setvar (while (and (or lst (and (setq e1 (entsel "\nSelect Entity: ")) (or (vl-position (cdr (assoc 0 (entget (car e1)))) '("ARC" "LINE" "LWPOLYLINE")) (alert "Invalid object!") ) ;_ or (setq lst (cons e1 lst)) ) ;_ and ) ;_ or (setq e2 (entsel "\nSelect next entity: ")) (or (vl-position (cdr (assoc 0 (entget (car e2)))) '("ARC" "LINE" "LWPOLYLINE")) (alert "Invalid object!") ) ;_ or (setq lst (cons e2 lst)) (vl-cmdf "_.fillet" (cadr lst) (car lst)) (or (zerop (getvar 'filletrad)) (setq lst2 (cons (list (entlast)) lst2))) ) ;_ and ) ;_ while (setq answer (getstring "\n Convert to LWPolyline? [ Press anykey = Yes / N = No ] : ")) (if (= (strcase answer) "N") (progn ) (progn (setq ss (ssadd)) (foreach x (append lst lst2) (setq ss (ssadd (car x) ss))) (if (zerop (getvar 'peditaccept)) (vl-cmdf "_.pedit" "_m" ss "" "_y" "_j" "" "") (vl-cmdf "_.pedit" "_m" ss "" "_j" "" "") ) ;_ if );end of progn );end of if (princ) ) ;_ defun how about this? Edited April 28, 2022 by exceed Quote
Dahzee Posted April 28, 2022 Author Posted April 28, 2022 Hi exceed, Works like a charm! Thank you much appreciated. Could you humour me and explain why it can't just be changed from No to Yes? Quote
exceed Posted April 28, 2022 Posted April 28, 2022 (edited) (initget 0 "Yes No") ; Limit the values you will receive with getkword below. Only yes and no are possible. (and (eq "Yes" (getkword "\nConvert to LWPolyline? [Yes/No] <No>: ")) ; When the value input by getkword is "Yes", ; the following is executed. Otherwise it won't run. ; The sentence between " " after getkword is just a message to the user, ; so changing it doesn't make any sense. ; Since it is written as <No>, it is written as if the default value is No, ; but it just does not work if it is not Yes. (setq ss (ssadd)) ; make empty selection set "ss" (foreach x (append lst lst2) (setq ss (ssadd (car x) ss))) ; add all of lst lst2 to ss (if (zerop (getvar 'peditaccept)) ; if pedit conversion alert is on (vl-cmdf "_.pedit" "_m" ss "" "_y" "_j" "" "") ; press "_y(=yes)" in routine (vl-cmdf "_.pedit" "_m" ss "" "_j" "" "") ; if off, without "_y" ) ;_ if ) ;_ and like this? Edited April 28, 2022 by exceed 1 Quote
Tharwat Posted April 28, 2022 Posted April 28, 2022 Just replace this: (eq "Yes" (getkword "\nConvert to LWPolyline? [Yes/No] <No>: ")) With this: (null (getkword "\nConvert to LWPolyline? [Yes/No] <Yes>: ")) When a user hits enter then the return will be nil otherwise user will be forced to press No to not to convert to LWpolyline. 2 Quote
Dahzee Posted April 28, 2022 Author Posted April 28, 2022 @exceed, thanks for the explanation, it all helps my learning. @tharwat, thanks for the answer, just goes to show there is more than one way of doing it, don't you just love lisp. Much appreciated both of you. Quote
Tharwat Posted April 28, 2022 Posted April 28, 2022 2 minutes ago, Dahzee said: @tharwat, thanks for the answer, just goes to show there is more than one way of doing it, don't you just love lisp. Certainly yes. Quote
BIGAL Posted April 28, 2022 Posted April 28, 2022 My $0.05 Multi radio buttons in downloads There is also a Acet yes no (SETQ reply (ACET-UI-MESSAGE "Choose dude " "Dahzee Dialog" (+ Acet:YESNOCANCEL Acet:ICONWARNING) ) ) 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.