Here’s a great routine that lets you break a polyline segment. Simply select the segment that you want to be a separate polyline entity from the ones that it was initially created with. This routine works on closed polylines line rectangles… But there is one glitch that I have found. When used on polygons, it creates an extra break.
Here’s how to use it:
- BSEG <enter> to start
- Select the segment on a polyline to break
- That’s it
Below is an example of the routine used on a polyline
Below is an example of the routine used on closed polylines and a polygon
(defun c:BSeg (/ *error* AT:GetSel _isLocked ent seg)
;; Break polyline Segment
;; Alan J. Thompson, 06.16.11
(vl-load-com)
(defun *error* (msg)
(and *AcadDoc* (vla-endundomark *AcadDoc*))
(if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
(princ (strcat "\nError: " msg))
)
)
(defun AT:GetSel (meth msg fnc / ent)
;; meth - selection method (entsel, nentsel, nentselp)
;; msg - message to display (nil for default)
;; fnc - optional function to apply to selected object
;; Ex: (AT:GetSel entsel "\nSelect arc: " (lambda (x) (eq (cdr (assoc 0 (entget (car x)))) "ARC")))
;; Alan J. Thompson, 05.25.10
(setvar 'ERRNO 0)
(while
(progn (setq ent (meth (cond (msg)
("\nSelect object: ")
)
)
)
(cond ((eq (getvar 'ERRNO) 7) (princ "\nMissed, try again."))
((eq (type (car ent)) 'ENAME)
(if (and fnc (not (fnc ent)))
(princ "\nInvalid object!")
)
)
)
)
)
ent
)
(defun _isUnLocked (layer) (/= 4 (logand 4 (cdr (assoc 70 (entget (tblobjname "LAYER" layer)))))))
(vla-startundomark
(cond (*AcadDoc*)
((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
)
)
(if (setq ent
(car (AT:GetSel entsel
"\nSelect polyline segment to break: "
(lambda (x / d p)
(if (and (_isUnLocked (cdr (assoc 8 (setq d (entget (car x))))))
(wcmatch (cdr (assoc 0 d)) "*POLYLINE")
(>= (cdr (assoc 90 d)) 3)
)
(setq seg (list (trans (vlax-curve-getPointAtParam
(car x)
(setq p (fix (vlax-curve-getParamAtPoint
(car x)
(vlax-curve-getClosestPointTo
(car x)
(trans (cadr x) 1 0)
)
)
)
)
)
0
1
)
(trans (cond ((vlax-curve-getPointAtParam (car x) (1+ p)))
((vlax-curve-getPointAtParam (car x) (1- p)))
)
0
1
)
)
)
)
)
)
)
)
(progn (vl-cmdf "_.break" ent "_F" "_non" (car seg) "_non" (car seg))
(vl-cmdf "_.break" (entlast) "_F" "_non" (cadr seg) "_non" (cadr seg))
)
)
(*error* nil)
(princ)
)


If i want remove various segments of differents polylines over the same place? Can you help me?
Juan,
I would try one of these tips:
This one allows you to break a polyline’s segment by selecting it.
https://autocadtips.wordpress.com/2011/10/07/autolisp-break-polyline-segments/
This one shows how you can select individual segments and then modify them however you choose.
https://autocadtips.wordpress.com/2011/08/29/select-individual-polyline-segment/