Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fillet multiple polyline all at once by lisp

30 REPLIES 30
SOLVED
Reply
Message 1 of 31
Anonymous
16963 Views, 30 Replies

Fillet multiple polyline all at once by lisp

Help me please,

 

Anybody know how to fillet selected polylines all at once by lisp.

30 REPLIES 30
Message 2 of 31
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

.... 

Anybody know how to fillet selected polylines all at once by lisp.


In simplest terms [very lightly tested], using whatever the current Fillet radius setting is:

 

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

Enhance with the usual stuff as desired, and/or with a request for a radius, allowing "heavy" 2D Polylines, etc.

Kent Cooper, AIA
Message 3 of 31
Anonymous
in reply to: Kent1Cooper

This code is working perfectly.Smiley Happy

 

Thank you Mr.Kent.

 

 

Message 4 of 31
muhamed_ragab92
in reply to: Anonymous

Not worked for me cad 2016 , please can you help me
Message 5 of 31


@muhamed_ragab92 wrote:
Not worked for me cad 2016 , please can you help me

It works for me in Acad2016.  Be more specific -- what about it doesn't work?  Does it not load?  Does it load, but not recognize the command name?  Does it recognize the command name, but something happens differently from what you expect, and if so, what?  Etc., etc.

 

Some possible causes:  Picking Polylines on locked Layers.  Picking "heavy" [whether 3D or 2D] rather than LightWeight Polylines.  Picking things that look like Polylines but are really collections of Lines/Arcs, or possibly other kinds of things [e.g. Regions].  Picking sharp-cornered Polylines but not setting a non-zero Fillet radius first.  If the current Fillet radius is not zero, picking Polylines that are too small for the current Fillet radius to round their corners.

Kent Cooper, AIA
Message 6 of 31
Anonymous
in reply to: Kent1Cooper

le agradezco pues mi estimado gracias, trabajare con esto para mis polígonos de manzanas 

Message 7 of 31
braudpat
in reply to: Kent1Cooper

Hello @Kent1Cooper 

 

Thanks for the routine !

 

I will do a Micro-Update for PLines Chamfer ...

 

Regards, Patrice (The Old French EE Froggy)

The Health - Stay Safe

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 8 of 31
rhgrafix
in reply to: Kent1Cooper

This doesn't work for me either. I have 10 rectangles, all lwPolylines with zero radii corners, I want to give them all .05" radii on all corners of each rectangle at one time, FMP does nothing and I don't know why. Is there another macro that is written differently? Thanks.
Message 9 of 31
ВeekeeCZ
in reply to: rhgrafix

Post a dwg with an examples of linework on which the routine fails.

Message 10 of 31
braudpat
in reply to: rhgrafix

Hello

 

Before using the routine FMP from Kent1Cooper,

PLEASE do a "classic" FILLET Command with the RIGHT Radius (for the future FMP) !

 

Because FMP is using the latest Fillet Radius, so it must be OK !!

 

The Health, Bye, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 11 of 31
Kent1Cooper
in reply to: rhgrafix


@rhgrafix wrote:
This doesn't work for me either. I have 10 rectangles, all lwPolylines with zero radii corners, I want to give them all .05" radii on all corners of each rectangle at one time, FMP does nothing ....

@braudpat rightly points out what these from my earlier Messages say:

[Message 2] .... using whatever the current Fillet radius setting is ....
[Message 5] Some possible causes [of its not working for @muhamed_ragab92 in Message 4] .... Picking sharp-cornered Polylines but not setting a non-zero Fillet radius first.

 

But you don't need to actually Fillet something to establish the desired radius.  You can just set the FILLETRAD System Variable before running the command.

 

If that's not the problem, maybe a drawing file would help.  But would you prefer a routine that asks you for a radius every time, rather than using whatever the current radius is?  That would be a fairly simple revision.

Kent Cooper, AIA
Message 12 of 31
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
.... would you prefer a routine that asks you for a radius every time, rather than using whatever the current radius is?  That would be a fairly simple revision.

Here's a less-than-simple revision, FilletMultiplePolylines.lsp [using the same FMP command name], including error handling, and remembering your radius.  See the comments at the top of the file.

 

It could be done differently in several ways:  It could always offer regular Fillet's radius setting as the default, and not store a radius from within the command.  It could be wrapped in Undo begin-end, so using U after it will undo all the Filleting it did, collectively.  It could report how many selected Polylines it did not Fillet [see reasons in the comments], or it might be possible to filter the selection to not accept those in the first place.  Etc.

Kent Cooper, AIA
Message 13 of 31
rhgrafix
in reply to: ВeekeeCZ

 It doesn't work in any file, someone changed the code to this and now it works:

(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)

)

 

Message 14 of 31
Kent1Cooper
in reply to: rhgrafix


@rhgrafix wrote:

 It doesn't work in any file, someone changed the code to this and now it works:

....


Well, that requires further explanation.  The only difference between that and the code in Message 2 [which you said in Message 8 didn't work for you, but that works for everyone else] is that the changed version allows selection of Polylines on locked Layers.  But it wouldn't be able to Fillet those anyway, so that should make no difference in the end result.

 

Maybe what requires explanation is exactly what you meant by "FMP does nothing" in Message 8.  Does it not load?  Does it load, but not recognize the command name?  Does it recognize the command name, but does not allow you to select anything?  [If so, is it because they're all on locked Layers?]  Does it allow selection, but nothing about the selected Polylines changes?  Are there any messages?  Run it so that it "does nothing," and post the command-line history.

Kent Cooper, AIA
Message 15 of 31
paliwal222
in reply to: Kent1Cooper

Thanks,

MULTI FILLET AND SEPERATE LAYER.jpgDoes it is possible,

Message 16 of 31
Kent1Cooper
in reply to: paliwal222


@paliwal222 wrote:

....

Does it is possible,


If each corner of the intersection was a Polyline that turned the corner, FMP would round all the corners.  But because of the different colors, that is clearly not the case.  It is a completely different operation, so I suggest starting a new Topic.  But when you do, post a small drawing file showing before and after, and a more detailed explanation.  [In particular, it's not clear to me what you mean by the "break at midpoint" note.  Should the Arc at the corner be split in the middle, and each half put on the Layer of the Line it connects to?  It doesn't look like that in zooming in on the image, but the resolution is not very good.]  Never mind -- I see you have done so.

Kent Cooper, AIA
Message 17 of 31
shaun.cavey
in reply to: Kent1Cooper

thanks for posting your code!  I slightly revised to do the same thing for Chamfer, as someone else did too.  

;batch chamfer multiple polylines
;uses pre-defined (default) distances of the chamfer command


(defun C:CMP ; = Chamfer Multiple Polylines
  (/ plss n)
  (if (setq plss (ssget "_:L" '((0 . "LWPOLYLINE"))))
    (repeat (setq n (sslength plss))
      (command "_.chamfer" "_polyline" (ssname plss (setq n (1- n))))
    ); repeat
  ); if
  (princ)
); defun
Message 18 of 31
Anonymous
in reply to: Kent1Cooper

Is there a way this code can work in reverse?  For instance, I am in the aluminum extrusion industry, all our shapes have to have a .016" fillet at all sharp corners, but our quality machine that rides the edges, and works off of a DXF file, doesn't like those fillets in the geometry.  I'd like to be able to apply those radii to get the correct weight per foot, or remove them to 90's to save a dxf, but I'd only want it to remove radius of .016".  Thanks in advance!

Message 19 of 31
Anonymous
in reply to: Kent1Cooper

Nevermind! I can use FILLETRAD and set it to 0.  As long as I use an ARC or chop a CIRCLE to get my random radii it won't effect those.  Awesome code!  Thanks!

Message 20 of 31
rhgrafix
in reply to: Anonymous

You should be able to set the radii to zero to remove all of your .016"
radii, if I understand you correctly.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report