Function Syntax: BTD / BoundaryTrim / BoundarySelect / EraseOutsideBoundary Version: 1.1 Date: 20.06.2026 6:38:50PM https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-trim-and-delete-entities-outside-of-a-closed-polyline-in/td-p/13247753 Description ๐Ÿš€ AutoTrimExtendLines is an AutoCAD and Civil 3D AutoLISP utility for trimming, extending, and cleaning selected drawing geometry to selected bounding edges from a custom DCL dialog. The main benefit is faster CAD geometry cleanup, fewer manual TRIM and EXTEND steps, better control over selected objects, and a repeatable Apply and Undo workflow. Main Commands ๐Ÿงฐ Run TTT to open the Touch / Trim-Extend to Edge v4 dialog. ๐Ÿงน Run TTTCLEAR to clear the stored debug log. SEO Optimized Description ๐Ÿ“ This AutoCAD AutoLISP tool uses selected bounding edges and selected objects to automatically move geometry endpoints to the closest valid intersection point. ๐Ÿ” The routine uses Visual LISP COM automation and ActiveX IntersectWith calculations to detect trim and extension targets between boundary objects and editable geometry. ๐Ÿง  It is useful for CAD technicians, Civil 3D designers, infrastructure drafting teams, and AutoCAD users who need to clean many lines, polylines, arcs, and splines against one or more reference edges. Primary Workflow ๐Ÿš€ Type TTT in the AutoCAD command line. 1๏ธโƒฃ Pick bounding edges such as lines, polylines, arcs, circles, splines, or ellipses. 2๏ธโƒฃ Pick the objects to modify, such as lines, polylines, arcs, and splines. 3๏ธโƒฃ Choose Trim only, Extend only, or Trim and Extend. 4๏ธโƒฃ Press Apply to process the drawing while keeping the dialog open, or press OK to apply and close. โ†ฉ๏ธ Use Undo Last to reverse the last operation with AutoCAD UNDO. Functionalities ๐Ÿš€ Dialog-driven trim and extend - opens a custom DCL interface instead of relying only on manual command-line trimming. ๐Ÿ“ Three edit modes - supports trim-only, extend-only, and combined trim-and-extend workflows. ๐Ÿงฑ Bounding edge selection - accepts LINE, LWPOLYLINE, POLYLINE, ARC, CIRCLE, SPLINE, and ELLIPSE entities as reference edges. โœ๏ธ Object modification selection - edits LINE, LWPOLYLINE, POLYLINE, ARC, and SPLINE objects where valid intersections are found. ๐Ÿ” Intersection-based calculation - uses ActiveX IntersectWith to find target trim and extend points. ๐ŸŸก Live selection highlight - highlights selected bounding edges and selected modify objects while the dialog is active. ๐Ÿ”„ Apply without closing - processes geometry, reopens the dialog, and keeps selections available for repeated cleanup operations. โ†ฉ๏ธ Undo support - wraps modifications in AutoCAD undo logic and provides an Undo Last button. ๐Ÿงพ Debug log viewer - displays processed entity types, intersection counts, distances, modified objects, and skipped objects. ๐Ÿ“‹ Copy log to clipboard - exports troubleshooting information through Windows clipboard support. ๐Ÿ’พ Dialog position memory - remembers the DCL dialog position during the AutoCAD session using the get_attr x/y pattern. ๐Ÿ”’ Safe cleanup logic - unloads temporary DCL files, clears highlights, and handles cancellation or errors safely. Technical Notes ๐Ÿงฉ The uploaded source header identifies the internal tool as Touch.LSP v4, while this SEO package uses the project name AutoTrimExtendLines. ๐Ÿ“Œ The routine includes helper functions such as Touch:Execute, Touch:Intersect, Touch:HighlightSS, Touch:CountStr, and Touch:WriteDCL. โš ๏ธ This tool modifies drawing geometry. Review results carefully and use Undo when required. Practical Result โœ… The final result is a faster AutoCAD trim and extend workflow for cleaning linework, adjusting endpoints, extending objects to boundaries, and reducing repetitive manual drafting operations. This SEO-friendly description highlights AutoCAD trim extend automation, Civil 3D drafting cleanup, DCL dialog control, ActiveX intersection logic, and AutoLISP productivity for CAD production environments. Tags ๐Ÿท๏ธ AutoCAD AutoLISP, Civil 3D LISP, AutoCAD trim extend, AutoCAD trim lines, AutoCAD extend lines, trim to boundary, extend to edge, AutoCAD geometry cleanup, AutoCAD DCL dialog, LISP DCL tool, AutoCAD productivity tool, CAD drafting automation, AutoCAD line cleanup, AutoCAD polyline edit, AutoCAD arc edit, AutoCAD spline edit, IntersectWith AutoLISP, Visual LISP COM, ActiveX AutoCAD, AutoCAD undo workflow, AutoCAD debug log, AutoCAD clipboard log, TTT command, TTTCLEAR command, Touch LSP, AutoTrimExtendLines