Jump to content

How can I write the code for a batch fillet plugin for images like this?


Recommended Posts

Posted

Drawing2.dwg

 

As shown in the figure below:
Select multiple graphics in batch and change the R value from 0.2 to another value?

 

ScreenShot_2026-01-30_151107_009.png.3c4f4910e2903544a5da95980a20ea86.png

Posted

Code what's that for ?

 

Join Fillet R 0.4 P pickobject enter

 

All done

  • Like 1
Posted
1 hour ago, BIGAL said:

Code what's that for ?

Join Fillet R 0.4 P pickobject enter

All done

 

Have to fillet the 3 long arcs segments before joining. But yes no lisp needed for simple task.

 

image.thumb.png.cee607824745901d591eafe6148cd61c.png

 

 

 

 

Posted (edited)

The large arc is like the base radius for all the teeth, so changing that may need a complete redraw. behind the shape must be some form of formula, or design rules.

 

Sounds like a custom gear.lsp is needed.

Edited by BIGAL
Posted

Much like Elvis, the OP seems to have left the building.

 

In case there is a dramatic return, here is a LISP that should work, though unclear what "code" they want or or if this is for an actual plug-in.

 

Solved: Fillet multiple polyline all at once by lisp - Autodesk Community

 

I didn't look at Kent Cooper's version to prompt for a radius, but used the original and added something simple to it. I am sure Kent Cooper's is better.

 

(defun C:FMP_R (/ plss n rad)
  (setq rad (getdist "\nEnter fillet radius: "))
  (if (and rad (> rad 0.0))
    (progn
      (command "_.fillet" "_radius" rad)
      (if (setq plss (ssget "_:L" '((0 . "LWPOLYLINE"))))
        (repeat (setq n (sslength plss))
          (command "_.fillet" "_polyline"
                   (ssname plss (setq n (1- n))))
        )
      )
    )
  )
  (princ)
)

 

  • Like 1
Posted (edited)

Lee Mac has a similar code.

The FMP_R and fpoly codes perform conjugations with a given radius. 
Only in these codes it is impossible to set the value radius = 0
Is there a code for interfacing with a radius of 0?

There's also the marko_ribar code, but I couldn't verify it. When loading, the message appears: Unknown command.

 

Edited by Nikon
Posted

Did you bother to check the link I posted?

 

The first one in my link from Kent Cooper will do fillet>R>0 if that is the value of  FILLETRAD.

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/fillet-multiple-polyline-all-at-once-by-lisp/m-p/6473166#M130031

 

 

The FilletMultiplePolylines will work with 0 radius.

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/fillet-multiple-polyline-all-at-once-by-lisp/m-p/10151411#M130041 

Posted
1 hour ago, SLW210 said:

Did you bother to check the link I posted?

Unfortunately, I couldn't check, the link doesn't open for me...

Posted
(defun C:FMP
(/ plss n)
(if (setq plss (ssget '((0 . "LWPOLYLINE"))))
(repeat (setq n (sslength plss))
(command "_.fillet" "_polyline" (ssname plss (setq n (1- n))))
); repeat
); if
(princ)

 

I guess this is it

  • Thanks 1
Posted (edited)
1 hour ago, GLAVCVS said:
(defun C:FMP
(/ plss n)
(if (setq plss (ssget '((0 . "LWPOLYLINE"))))
(repeat (setq n (sslength plss))
(command "_.fillet" "_polyline" (ssname plss (setq n (1- n))))
); repeat
); if
(princ)

This code should perform the pairing (without specifying the radius?). The code doesn't work: unknown command.

The parenthesis after (princ) is lost. +)

Edited by Nikon
Posted (edited)
6 hours ago, SLW210 said:

The first one in my link from Kent Cooper will do fillet>R>0 if that is the value of  FILLETRAD.

The code can connect several polylines with a radius of 0.

I understood that FILLETRAD must be set beforehand.

Or do this:

(defun C:FMP0 ; = Fillet Multiple Polylines
  (/ plss n)
(setvar "FILLETRAD" 0)
  (if (setq plss (ssget '((0 . "LWPOLYLINE"))))
    (repeat (setq n (sslength plss))
      (command "_.fillet" "_polyline" (ssname plss (setq n (1- n))))
    ); repeat
  ); if
  (princ)
); defun

Or a different code for different radii, and you can also use 0.

(defun C:FMP01 (/ rad plss n)
  (setq rad (getreal "
Enter the fillet radius (you can use 0): "))
  (setvar "FILLETRAD" rad)
  (if (setq plss (ssget '((0 . "LWPOLYLINE"))))
    (repeat (setq n (sslength plss))
      (command "_.fillet" "_polyline" (ssname plss (setq n (1- n))))
    )
  )
  (princ)
)

 

Edited by Nikon
Posted
1 hour ago, Nikon said:

This code should perform the pairing (without specifying the radius?). The code doesn't work: unknown command.

The parenthesis after (princ) is lost. +)

 

Phew!

I just copied and pasted from the link you requested. 😅
For some reason, the final parenthesis got lost.

But I see that the code suggested here is already more complete.

 

Deprecated!

  • Agree 1
Posted

Here is the one from Kent Cooper, though it seems suspicious you would be blocked from the Autodesk Forums.

 

This is the one that asks for the radius and will accept 0 radius.

 

;| FilletMultiplePolylines.lsp [command name: FMP]
Asks for desired Fillet radius, offering default of prior value if present, otherwise
  regular Fillet's value, as default.  Asks for selection of Polylines, and Fillets all
  possible corners at specified radius.  Restores regular Fillet's radius setting, but
  stores setting from this command separately, for default on subsequent use.
Works on LightWeight and "heavy" 2D Polylines except those that are Fit- or
  Spline-curved.  Accepts selection of those, and of 3D Polylines, but does not
  process them.
|;
;;;
;;; By Kent Cooper
;;;
;;; Found here https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/fillet-multiple-polyline-all-at-once-by-lisp/m-p/10151411#M130041


(defun C:FMP ; = Fillet Multiple Polylines
  (/ *error* doc filr plss n pl)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    ); if
    (setvar 'filletrad filr); reset
    (vla-endundomark doc)
    (princ)
  ); defun - *error*
  (vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object))))
  (setq filr (getvar 'filletrad)); save current setting
  (initget 4); no negative
  (setq *fmpr* ; global variable
    (cond
      ( (getdist
          (strcat
            "\nRadius for Filleting all Polyline corners <"
            (rtos (cond (*fmpr*) ((getvar 'filletrad))))
              ; prior value as default if present; if not, regular Fillet radius
            ">: "
          ); strcat
        ); getdist            
      ); User-input condition
      (*fmpr*); prior value if present on Enter
      ((getvar 'filletrad)); regular Fillet radius if no prior value on Enter
    ); cond
  ); setvar
  (setvar 'filletrad *fmpr*)
  (if (setq plss (ssget "_:L" '((0 . "*POLYLINE"))))
    (repeat (setq n (sslength plss))
      (setq pl (ssname plss (setq n (1- n))))
      (if (= (logand (cdr (assoc 70 (entget pl))) 30) 0); not 3D, fit- or spline-curved 
        (command "_.fillet" "_polyline" pl); then
      ); if
    ); repeat
  ); if
  (setvar 'filletrad filr)
  (vla-endundomark doc)
  (princ)
); defun
(vl-load-com)
(prompt "\nType FMP to Fillet Multiple Polylines.")

 

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