I want to enhance this LISP

I want to enhance this LISP

carminatithekid1
Enthusiast Enthusiast
1,070 Views
6 Replies
Message 1 of 7

I want to enhance this LISP

carminatithekid1
Enthusiast
Enthusiast

I am looking for someone to tell me what to place in this lisp, and where, so the command will repeat.

 

(defun c:d_fillet (/ dscale fill_rad pt1 pt2)
(princ "\nCUSTOM FILLET")
(setq dscale (getvar "dimscale"))
(princ " Current Dimscale is: ")(princ dscale)
(setq fill_rad 0.1)
(setq fill_rad (* dscale fill_rad))
(while (null (setq PT1 (entsel "\nSelect first line: ")))
(princ "\nNo object found")
)
(redraw (car PT1) 3)
(while (null (setq PT2 (entsel "\nSelect second line: ")))
(princ "\nNo object found")
)
(redraw (car PT2) 3)
(command "fillet" "rad" (rtos fill_rad)
"fillet" pt1 pt2)
(redraw (car PT1) 4)
(redraw (car PT2) 4)
(princ)
)

Randy Carminati
0 Likes
Accepted solutions (2)
1,071 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

Like this?

 

(defun c:d_fillet (/ pt1 pt2)

  (princ "\nCUSTOM FILLET")
  (command "_.FILLET" "_Rad" (rtos (* (getvar 'DIMSCALE) 0.1)))

  (princ "\nCurrent Dimscale: ") (princ (getvar 'DIMSCALE))
  (princ "\nCurrent Radius: ") (princ (getvar 'FILLETRAD))
  
  (while (setq PT1 (entsel "\nSelect first line <done>: "))
    (redraw (car PT1) 3)
    (while (null (setq PT2 (entsel "\nSelect second line: ")))
      (princ "\nNo object found"))
    (redraw (car PT2) 3)
    (command "_.FILLET" pt1 pt2)
    (redraw (car PT1) 4)
    (redraw (car PT2) 4))
  (princ)
  )

While - you'll pick some first line - then you can continue the selection the other and fillet those...

Message 3 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

I am looking for someone to tell me what to place in this lisp, and where, so the command will repeat.

....


How about simply making use of the Multiple option in the Fillet command?  Much simpler, because the Fillet command itself will also take care of much of what your code does [e.g. asking again if you miss, highlighting]:

 

(defun c:d_fillet ()
  (princ "\nCUSTOM FILLET")
  (princ " Current Dimscale is: ") (princ (getvar "dimscale"))
  (setvar 'filletrad (* (getvar "dimscale") 0.1))
  (command "_.fillet" "_multiple")
)
Kent Cooper, AIA
Message 4 of 7

carminatithekid1
Enthusiast
Enthusiast

Can I ask to have you guys help me simplify this code as well? Very similar to the previous fillet, but I now want a chamfer tool that takes into account the current dimscale and will also keep going without having to start the command again.

 

(defun c:d_chamfer (/ dscale cham_dist pt1 pt2)
(setvar "cmdecho" 0)
(setq dscale (getvar "dimscale"))
(princ " Current Dimscale is: ")(princ dscale)
(setq cham_dist 0.1)
(setq cham_dist (* dscale cham_dist))
(while (null (setq PT1 (entsel "\nSelect first line: ")))
(princ "\nNo object found")
)
(redraw (car PT1) 3)
(while (null (setq PT2 (entsel "\nSelect second line: ")))
(princ "\nNo object found")
)
(redraw (car PT2) 3)
(command "chamfer" "d" (rtos cham_dist) ""
"chamfer" pt1 pt2
)
(redraw (car PT1) 4)
(redraw (car PT2) 4)
(princ)
)

Randy Carminati
0 Likes
Message 5 of 7

ВeekeeCZ
Consultant
Consultant

Actually it is pretty much the same. So how about take Kent's version as the pattern, look into the HELP what variables you need to set and try to rewrite it by youself. If you'll get stuck, post the code here.

Good luck!

Message 6 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... I now want a chamfer tool that takes into account the current dimscale and will also keep going without having to start the command again.

....


That has a Multiple option, too:

(defun c:d_chamfer (/ dscale)
  (princ "\nCUSTOM CHAMFER")
  (setq dscale (getvar "dimscale"))
  (princ " Current Dimscale is: ") (princ dscale)
  (setvar 'chamfera (* dscale 0.1))
  (setvar 'chamferb (* dscale 0.1))
  (command "_.chamfer" "_multiple")
)
Kent Cooper, AIA
Message 7 of 7

carminatithekid1
Enthusiast
Enthusiast

Thanks Kent! I appreciate it. I haven't had the time to learn a lot about lisp but I will be taking classes soon to learn. I appreciate all your guys' help.

 

If you know of any good sites to assist me, I would greatly appreciate it. I am wanting to learn the most simple, yet basic, way of coding. I am wanting to update all of our coding due to the new method of work and new requests from designers.

 

Thanks again.

Randy Carminati
0 Likes