gpd Posted March 6, 2011 Posted March 6, 2011 Hi All I am trying to write some code which prompts uer to pick 2 lines and then fillets them with radius value of 0.5 Now the question is that sometimes 0.5 radius value may not be suitable for selected lines and running the fillet command my generate an error with messag "Radius value too large". I want to write such code which applies fillet to the selected lines and if radius value is not suitable then instead of generating error, it reduces the radius value by lets say 0.1 and runs fillet again. If error occurs again the program again reduces the fillet radius value and continueus unless a workable radius value is found. Please give some guidance about writing such code. Thanks. Quote
fixo Posted March 6, 2011 Posted March 6, 2011 Give this a shot, change the command DEMO on appropriate name if it is needed (defun c:demo (/ fil line1 line2 rad) (setq fil (getvar "filletrad" )) (initget 6) (setq rad (getreal "\nEnter initial radius <25>: ")) (if (not rad)(setq rad 25)) (setvar "filletrad" rad) (cond ((and (setq line1 (car (entsel "\nSelect first line: "))) (setq line2 (car (entsel "\nSelect second line: ")))) (while (not (vl-cmdf "_fillet" line1 line2 )) (setvar "filletrad" (setq rad (- rad 0.1)))))) (setvar "filletrad" fil) (princ) ) ~'J'~ Quote
pBe Posted March 17, 2011 Posted March 17, 2011 I never realize error checking can be done this way... .......(while (not (vl-cmdf "_fillet" line1 line2 ))..... Very nice Fixo 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.