Naveen Rayalla e-mailed a request to delete all entities touching and outside of a circle in AutoCAD. To trim all entities outside of a circle using the regular AutoCAD Trim command, the user first selects the Trim tool, selects the circle as a cutting edge or boundary and then makes a series of fences or selects individual entities, depending on how many entities are to be trimmed. When there are many entities, such as those shown below, the process can be time consuming. Our AutoLISP Solution is a CIRC-TRIM.LSP, a routine that trims everything outside of a circle when the user simply selects the circle. Because the solution is rather short, I have included a bonus AutoLISP Solution to convert circles to polylines.
In my job as professor of technology at Buffalo State College, I use the VALCAM CAD-CAM system that I wrote in AutoLISP to work inside AutoCAD. The CNC code generator uses polylines for machining, so the students convert all of the entities to be machined into polylines. AutoCAD doesn't convert circles into polylines, and it's tedious to draw arcs instead of circles and then convert those to polylines. The solution CIR-TO-PLINE.LSP does the job automatically for any selected circles.
Get the Code Download the CIRC-TRIM.LSP and CIR-TO-PLINE.LSP files from our Get the Code area and save them in AutoCAD's Support directory. Use the Appload facility by selecting Tools/Load Application, and then select CIRC-TRIM.LSP for trimming outside of a circle and CIR-TO-PLINE.LSP to convert circles to polylines.


 |