Jump to content

Recommended Posts

Posted

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

 

Posted (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 by exceed
Posted

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?

Posted (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 by exceed
  • Like 1
Posted

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.

  • Like 2
Posted

@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.

Posted
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. :) 

 

Posted

My $0.05

 

Multi radio buttons in downloads

image.png.f59ff75dcbfea59810e3e60f55e436dc.png

 

There is also a Acet yes no 

 

(SETQ reply (ACET-UI-MESSAGE "Choose dude "
                             "Dahzee Dialog"
                             (+ Acet:YESNOCANCEL Acet:ICONWARNING)
            )
)

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...