Jump to content

Help Creating an ARC lisp


PAWEL17

Recommended Posts

@Erhanask

Here is how you make this program work like the FILLET command in the sense that it will use the last default radius until you select the keyword "Radius" or "R" to change it. Look at my comment in the code to set the initial default if you are in a new drawing. I have currently just used 0.5, but you can set it to something more appropriate for your scale.

 

;; original code written by Lee Mac. Altered By P. Kenewell
(defun c:qarc ( / a b c r z )
   (setq z (trans '(0 0 1) 1 0 t)
         a (angle '(0 0) (trans (getvar 'ucsxdir) 0 z t))
         b (+ a 4.712388980384689)
   )
   (if (not qarc:def)(setq qarc:def 0.5)) ;Set the default radius to your preference
   (setq r qarc:def)
   (princ (strcat "\nCurrent Radius = " (rtos r 2 3)))
   (initget "Radius")
   (while (setq c (getpoint "\nArc center [Radius]: "))
       (if (= c "Radius")
          (if (not (setq r (getdist (strcat "\nSpecify arc radius <" (rtos qarc:def 2 3) ">: "))))
             (setq r qarc:def)
             (setq qarc:def r)
          )
          (entmake
              (list
                 '(000 . "ARC")
                  (cons 040 r)
                  (cons 050 a)
                  (cons 051 b)
                  (cons 010 (trans c 1 z))
                  (cons 210 z)
              )
          )
       )
       (initget "Radius")
   )
   (princ)
)

@Lee Mac may have a more efficient way to code this.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On 3/8/2021 at 6:17 PM, pkenewell said:

@Erhanask

Here is how you make this program work like the FILLET command in the sense that it will use the last default radius until you select the keyword "Radius" or "R" to change it. Look at my comment in the code to set the initial default if you are in a new drawing. I have currently just used 0.5, but you can set it to something more appropriate for your scale.

 


;; original code written by Lee Mac. Altered By P. Kenewell
(defun c:qarc ( / a b c r z )
   (setq z (trans '(0 0 1) 1 0 t)
         a (angle '(0 0) (trans (getvar 'ucsxdir) 0 z t))
         b (+ a 4.712388980384689)
   )
   (if (not qarc:def)(setq qarc:def 0.5)) ;Set the default radius to your preference
   (setq r qarc:def)
   (princ (strcat "\nCurrent Radius = " (rtos r 2 3)))
   (initget "Radius")
   (while (setq c (getpoint "\nArc center [Radius]: "))
       (if (= c "Radius")
          (if (not (setq r (getdist (strcat "\nSpecify arc radius <" (rtos qarc:def 2 3) ">: "))))
             (setq r qarc:def)
             (setq qarc:def r)
          )
          (entmake
              (list
                 '(000 . "ARC")
                  (cons 040 r)
                  (cons 050 a)
                  (cons 051 b)
                  (cons 010 (trans c 1 z))
                  (cons 210 z)
              )
          )
       )
       (initget "Radius")
   )
   (princ)
)

@Lee Mac may have a more efficient way to code this.

On 3/8/2021 at 6:17 PM, pkenewell said:

@Erhanask

Here is how you make this program work like the FILLET command in the sense that it will use the last default radius until you select the keyword "Radius" or "R" to change it. Look at my comment in the code to set the initial default if you are in a new drawing. I have currently just used 0.5, but you can set it to something more appropriate for your scale.

 


;; original code written by Lee Mac. Altered By P. Kenewell
(defun c:qarc ( / a b c r z )
   (setq z (trans '(0 0 1) 1 0 t)
         a (angle '(0 0) (trans (getvar 'ucsxdir) 0 z t))
         b (+ a 4.712388980384689)
   )
   (if (not qarc:def)(setq qarc:def 0.5)) ;Set the default radius to your preference
   (setq r qarc:def)
   (princ (strcat "\nCurrent Radius = " (rtos r 2 3)))
   (initget "Radius")
   (while (setq c (getpoint "\nArc center [Radius]: "))
       (if (= c "Radius")
          (if (not (setq r (getdist (strcat "\nSpecify arc radius <" (rtos qarc:def 2 3) ">: "))))
             (setq r qarc:def)
             (setq qarc:def r)
          )
          (entmake
              (list
                 '(000 . "ARC")
                  (cons 040 r)
                  (cons 050 a)
                  (cons 051 b)
                  (cons 010 (trans c 1 z))
                  (cons 210 z)
              )
          )
       )
       (initget "Radius")
   )
   (princ)
)

@Lee Mac may have a more efficient way to code this.

 

Link to comment
Share on other sites

  • 4 weeks later...
30 minutes ago, devitg said:

@ pkenewell  ,  why not to use  ? 


( + a ( * pi 1.5)) 

 Instead of 

 

 


(+ a 4.712388980384689)

 

 

@devitg That would work fine. I just did not want to change Lee's code any more than necessary.

Link to comment
Share on other sites

2 hours ago, devitg said:

Ok, so I should ask  Lee. 

Thanks 

 

@devitg I am saying that your alternate piece of code will work the same if you want to use it.

Link to comment
Share on other sites

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