Jump to content

Recommended Posts

Posted

Hello everyone,  when we work with cad, can we do the command like follows:

F0.5 to Fxxx= fillet with a radius 0.5mm(or xxx) directly, not like the traditional way:

Command: F
FILLET
Current settings: Mode = TRIM, Radius = 0.0000
Select first object or [Undo/Polyline/Radius/Trim/Multiple]: r
Specify fillet radius <0.0000>: 0.5
Select first object or [Undo/Polyline/Radius/Trim/Multiple]:

And c1~c255, command means change obj color to red to color 255.

Thanks a lot for your help.

 

 

Posted

Those two are simple enough that you should try writing your first lisp.

Set the value of the system variable FILLETRAD to 0.5 using setvar.

Then start the FILLET command. 

 

If you have trouble post your code for more help.

 

For the second one do you mean color from red to 255? One object or multiple? Do you need to filter a selection set for just those colored red?

You get better help by describing exactly what you want.

Search with Google or at the top of this page for what you need. Hundreds of fillet lisp threads out there like 

 

  • Like 2
Posted (edited)

This is what I use for common fillets.

 

--edit

Its set to run multiple but only draw back is if you miss click on like the 20th fillet and hit Esc it will undo all fillets. so if you mess up just exit out of the command and fix the one mistake.

Also only temp overrides the fillet radius for the commands.

 

--edit

oops sorry Tombu

 

(defun C:F1 () (frx "0.0625"))
(defun C:F2 () (frx "0.125"))
(defun C:F3 () (frx "0.250"))
(defun C:F4 () (frx "0.375"))
(defun C:F5 () (frx "0.500"))

;;----------------------------------------------------------------------;;
;; Quick Fillet with set radius
(defun frx (x / *error* ofr)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    )  ; if
    (setvar 'filletrad ofr)
  )
  (setvar "cmdecho" 0)
  (setq ofr (getvar 'filletrad))
  (vl-cmdf "_.Fillet" "_Radius" x "_.Fillet" "_Multiple")
  (setvar "cmdecho" 1)
  (princ (strcat "\nFillet (radius=" x "):  Select first entity or [Fillet Settings.../Polyline/Radius/Trim/Undo/Multiple]:"))
  (while (> (getvar 'cmdactive) 0) (command pause))
  (setvar 'filletrad ofr)
  (princ)
)

 

Edited by mhupp
  • Like 1
  • Thanks 1
Posted

@mhupp

As usual - your lisp are effective,clear and as simple as it can be!

I've added one more option - to let the user to choose the fillet radius (option FF):

 

(defun C:F1 () (frx "0.0625"))
(defun C:F2 () (frx "0.125"))
(defun C:F3 () (frx "0.250"))
(defun C:F4 () (frx "0.375"))
(defun C:F5 () (frx "0.500"))
(defun C:FF (/ FRad)
                 (setq FRad (getreal "\nFillet Radius<0>: "))
                    (if (= FRad nil)
                      (setq FRad 0)
                    )
(frx (rtos FRad 2 3))    
)
;;----------------------------------------------------------------------;;
;; Quick Fillet with set radius
(defun frx (x / *error* ofr)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    )  ; if
    (setvar 'filletrad ofr)
  )
  (setvar "cmdecho" 0)
  (setq ofr (getvar 'filletrad))
  (vl-cmdf "_.Fillet" "_Radius" x "_.Fillet" "_Multiple")
  (setvar "cmdecho" 1)
  (princ (strcat "\nFillet (radius=" x "):  Select first entity or [Fillet Settings.../Polyline/Radius/Trim/Undo/Multiple]:"))
  (while (> (getvar 'cmdactive) 0) (command pause))
  (setvar 'filletrad ofr)
  (princ)
)

 

and again - well done!!

Regards,

aridzv.

 

  • Like 2
Posted (edited)

Thank you for the kind words.

 

getdist is a little better because you can use things like 6' or 5 1/4

 

(defun C:FF (/ FRad) 
  (or (setq FRad (getdist "\nFillet Radius<0>: ")) (setq FRad 0)) ;ronjonp trick
  (frx (rtos FRad 2 3))
)

 

Have another one.

This is used if you want to mach an existing fillet but don't know the radius.

allows you to select anything that has a center point and matches it's radius. Then goes into the fillet command.  You could feed this into frx but i like to keep the radius change.

 

;;----------------------------------------------------------------------------;;
;; Apply the radius of a selected curved object in the Fillet command
(defun C:RR (/ ent pt r)
  (if (setq ent (entsel "Select Curve: "))
    (progn
      (setq pt (cadr ent))
      (if (setq r (distance (osnap pt "nea") (osnap pt "cen")))
        (progn ;could use frx here if you don't want to keep the radius
          (setvar 'filletrad r)
          (vl-cmdf "_.fillet" "M")
        )
        (prompt "\nNo Radius Found.")
      )
    )
  )
  (princ)
)

 

Edited by mhupp
  • Thanks 1
Posted

You may have found this if you google, it does exactly what you want type Fxxx and it sets fillet to that radius, there is also Cxxx for circles and offset more could be added. There is one little quirk with the program because it uses error trapping you enter 1.5 as 1-5 the "-" is used as a decimal point, if you enter F1.5 it will error as the error check finds the "." and treats the error check method differently. 

 

; Enter the filet radius as part of a command line entry f100, offset O234, circle c123-45, P123 for pline width
; note - is used for decimal point
; original code and methology by Alan H
; assistance and code that worked by Lee-Mac
; OCT 2015
 
(   (lambda nil
        (vl-load-com)
        (foreach obj (cdar (vlr-reactors :vlr-command-reactor))
            (if (= "fillet-reactor" (vlr-data obj))
                (vlr-remove obj)
            )
        )
        (vlr-command-reactor "fillet-reactor" '((:vlr-unknowncommand . fillet-reactor-callback)))
    )
)

(defun plwid ( / width oldwidth)
(setq width (distof (substr com 2) 2))
            (setq oldwidth (getvar 'plinewid))
            (if (<= 0.0 width)
              (progn
	      (setvar 'plinewid width )
              (vla-sendcommand fillet-reactor-acdoc "_.pline ")
              (setvar 'plinewid oldwidth)
              )
            ) 
)
(defun filletrad ( / rad)
(setq rad (distof (substr com 2) 2))
            (if (<= 0.0 rad)
              (progn        
              (setvar 'filletrad rad)
              (vla-sendcommand fillet-reactor-acdoc "_.fillet ")
              )
              ) 
)
(defun makecirc ( / rad)
(setq rad (distof (substr com 2) 2))
            (if (<= 0.0 rad)
            (progn        
            (setvar 'circlerad rad)
            (vla-sendcommand fillet-reactor-acdoc "_.Circle ")
            )
            )
)
(defun offdist ( / dist)
(setq dist (distof (substr com 2) 2))
            (if (<= 0.0 dist)
            (progn        
            (setvar 'offsetdist dist)
            (vla-sendcommand fillet-reactor-acdoc "_.Offset  ")
            )
            )
)

(defun fillet-reactor-callback ( obj com )
(setq com (vl-string-translate "-" "." (strcase (car com))))
    (cond   
        (   (and
            (wcmatch com "~*[~F.0-9]*")
            (wcmatch com "F*")
            (wcmatch com "~F*F*")
            (wcmatch com "~*.*.*")
            ) ; and
            (filletrad) 
         ) 

         (  (and
            (wcmatch com "~*[~C.0-9]*")
            (wcmatch com "C*")
            (wcmatch com "~C*C*")
            (wcmatch com "~*.*.*")
            ) ;and
            (makecirc) 
         )

         (  (and
            (wcmatch com "~*[~O.0-9]*")
            (wcmatch com "O*")
            (wcmatch com "~O*O*")
            (wcmatch com "~*.*.*")
            ) ; and
            (offdist) 
         )

         (  (and
            (wcmatch com "~*[~P.0-9]*")
            (wcmatch com "P*")
            (wcmatch com "~P*P*")
            (wcmatch com "~*.*.*")
            ) ; and
            (plwid) 
         )

    ) ; master cond
) ; defun

(princ)
 
(or fillet-reactor-acdoc
    (setq fillet-reactor-acdoc (vla-get-activedocument (vlax-get-acad-object)))
)
(princ)

; next Point or option keyword required.

 

  • Like 2
Posted (edited)

@mhupp

You are most welcome!!

1. about the getdist - Although I am not a person of imperial measurements but of metric measurements, this is an important option because it allows the user to get the radius from objects in the drawing itself, so at least for me it is one more function and not a replacement for getreal function - thanks for that, I have added it to my lisp, and thanks to @ronjonp as well for that trick.

2. about the second one, the option to get the radius from any object that has a center point - NICE!!!...

added as well!

 

thanks (Again... 🙂 )

aridzv.

 

*Comment:

for me the first functions (F1,F2, etc') are quite unnecessary, Mainly after you added the last two functions - by distance on the drawing and by radius of an object,

so I went with these three functions (radius as number, radius from dist between objects and radius from a curve) and gave up the first ones.

Edited by aridzv
  • Like 1
Posted
2 hours ago, aridzv said:

for me the first functions (F1,F2, etc') are quite unnecessary...

 

I agree but like I said before those are common fillet sizes I use daily (matched to cnc router bits). So when I'm designing its 2nd nature just to hit F#.

Posted

@mhupp

just realised that the getdist ( @ronjonp trick) covers both user input and selecting distance by points on the drawing,

so only 2 function are needed for me ( the FF and the RR).

  • Like 1
Posted

🤣 and I just realized your not the original poster, but glad i could help out.

 

@BIGAL Interesting code tho I don't do much with reactors. don't know where the error is coming from but i see your converting the - back into a decimal point then using wcmatch

 

Have a look at this might fix the error your getting.

Turns  "F5.125" into ("F" "5" "." "125")

(wcmatch (car com) "F") ?

 

 

;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-separe-number-and-string-in-the-same-string/m-p/2806136/highlight/true#M292581
(defun splitstring (str / isNum strlist strtemp strIsNum result)
  (defun isNum (char)
    (wcmatch char "#")
  )
  (setq strlist (mapcar 'chr (vl-string->list str))
        strtemp ""
        strIsNum (IsNum (car strlist))
  )
  (foreach item strlist
    (if (= (isNum item) strIsNum)
      (setq strtemp (strcat strtemp item))
      (setq result (append result (list strtemp))
            strIsNum (isNum item)
            strtemp item
      )  ; end setq
    )    ; end if
  )      ; end foreach
  (setq result (append result (list strtemp)))
)        ; end defun

 

Posted

For Mhupp possible but any "Fblahblah" would get caught then need to be secondary checked I guess could do 2nd character is 1-9 so keep going. 

 

Happy for you to have a go I just got used to using 1-5.

 

Whilst I think its a smart way to do stuff v's as hinted using fixed common sizes it will probably depend on the user industry. I have numerous defuns that are like this but use numbers, no need for the "F", 625, 125, 250, 375, 500.

 

(defun C:625 () (frx "0.0625"))

Posted (edited)

@BIGAL Basically have the same code for offset so F for fillets O for offsets.

 

Couldn't get your code to work (must be doing something wrong or BricsCAD)  or my code either but matches the same outputs.

 

--edit

prob don't need the split string function.

 

; Enter the filet radius as part of a command line entry f100, O234 for offset, c123.45 for circle, P123 for pline width
; original code and methology by Alan H
; assistance and code that worked by Lee-Mac
; OCT 2015

((lambda nil
  (vl-load-com)
  (foreach obj (cdar (vlr-reactors :vlr-command-reactor))
    (if (= "fillet-reactor" (vlr-data obj))
      (vlr-remove obj)
    )
  )
  (vlr-command-reactor "fillet-reactor" '((:vlr-unknowncommand . fillet-reactor-callback)))
 )
)

(defun plwid (/ oldwidth)
  (setq oldwidth (getvar 'plinewid))
  (setvar 'plinewid num)
  (vla-sendcommand fillet-reactor-acdoc "_.pline ")
  (setvar 'plinewid oldwidth)
)
(defun filletrad ()
  (setvar 'filletrad num)
  (vla-sendcommand fillet-reactor-acdoc "_.fillet ")
)
(defun makecirc ()
  (setvar 'circlerad num)
  (vla-sendcommand fillet-reactor-acdoc "_.Circle ")
)
(defun offdist ()
  (setvar 'offsetdist num)
  (vla-sendcommand fillet-reactor-acdoc "_.Offset ")
)
(defun fillet-reactor-callback (obj com / num)
  (setq com (car com))
  (cond
    ((and
      (eq (strcase (substr com 1 1)) "F")
      (numberp (setq num (distof (substr com 2))))
      (<= 0.0 num)
     )  ; and
      (filletrad)
    )

    ((and
      (eq (strcase (substr com 1 1)) "C")
      (numberp (setq num (distof (substr com 2))))
      (<= 0.0 num)
     )  ;and
      (makecirc)
    )

    ((and
      (eq (strcase (substr com 1 1)) "O")
      (numberp (setq num (distof (substr com 2))))
      (<= 0.0 num)
     )  ; and
      (offdist)
    )
    ((and
      (eq (strcase (substr com 1 1)) "P")
      (numberp (setq num (distof (substr com 2))))
      (<= 0.0 num)
     )  ; and
      (plwid)
    )
  )     ; master cond
)       ; defun

(or fillet-reactor-acdoc 
    (setq fillet-reactor-acdoc (vla-get-activedocument (vlax-get-acad-object)))
)

 

Edited by mhupp
  • Like 1
Posted (edited)

Yes works in Acad not Bricscad. I will ask Bricscad for maybe why not, they do reply have asked before.

 

Mhupp your code the "." problem 

Command: C100.5
Unknown command "5".  Press F1 for help.
 

Edited by BIGAL
  • Like 1

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