Jump to content

Recommended Posts

Posted

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.

Posted

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'~

  • 2 weeks later...
Posted

I never realize error checking can be done this way...

 

.......(while (not (vl-cmdf "_fillet" line1 line2 ))..... 

 

Very nice Fixo :)

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