Hello all
i've desperatly tried to find in this invaluable ng, a lisp routine to
remove vertex by *selecting* segment of a polyline instead of the
vertex
so here below is what i end up doing
(feel free to comment or redirect to a more "sexy way" of doing it)
(defun c:rs()
;***
;remove a segment of polyline by deleting the first point of that segment
;beware : arc segment case is not well handled => drop routine (or equivalent) should also remove point's 40/41/42 attribs values
;***
(if (setq ent (entsel))
(progn
(command "_CONVERTPOLY" "_H" (car ent) "")
(setq a (car (nentselp "" (cadr ent))))
(if (= 0 (logand 1 (cdr (assoc 70 (entget (car ent))))));polyline is not closed.. if we've selected a pline 😉
(progn
(if (= "SEQEND" (cdr (assoc 0 (entget (entnext (entnext a))))))
(progn
;have to insert here choice to delete last vertex or last segment
(initget "Segment Vertex")
(setq respsv (getkword "\nSuppress last Segment or last Vertex ?: "))
(if (or (not respsv) (= "Vertex" respsv))
;chose to supress last vertex by default
(setq a (entnext a))
)
)
)
)
)
(setq p2rm (cdr (assoc 10 (entget a))))
(setq p2rm (list (car p2rm) (cadr p2rm)))
(command "_CONVERTPOLY" "_L" (car ent) "")
(setq lwp (entget (car ent)))
;here only removing point is enough to recreate lwpolyline
;but it doesn't remove 40,42,42 values of that point
;so arc segment are not well removed
(setq lwp (drop (cons 10 p2rm) lwp))
(entmod lwp)
)
)
)
(defun drop(item lst)
;***
;http://groups.google.fr/group/autodesk.autocad.customization/browse_thread/thread/9eb77e820b39bf7f/30362c2ff175b7be?hl=fr&lnk=st&q=remove+segment+group%3Aautodesk.*&rnum=3#30362c2ff175b7be
;***
(append (reverse (cdr (member item (reverse lst))))
(cdr (member item lst))
)
)