Bonjour @mikael.macial
I've tried to use chatgpt to generate some, but none of them worked.
this is a real false good idea, this is false advertising this AI
I’m not sure if @komondormrex 's answer is correct based on the question. Because the last vertex has to stay
You ask to remove the 3rd last (ante penultimate) and 2nd last (penultimate) leaving the last one in place
Then I propose this, the command name is TEST :
(defun removenth (n lst / i rtn);found on the swamp by Jeff_M
(reverse (progn (setq i -1)
(foreach x lst (if (/= n (setq i (1+ i)))(setq rtn (cons x rtn))))
rtn)
)
)
(defun delpa (ent / coords coords2)
;Lisp to remove the penultimate and antepenultimate vertices of multiple polylines
(if
(and (>= (cdr (assoc 90 (entget ent))) 4)
(setq ent (vlax-ename->vla-object ent))
)
(progn
(setq coords (vlax-get ent 'coordinates))
(setq coords2 coords)
(setq len (length coords))
(setq pos (- len 3))
(repeat 4 (setq coords (removenth (- (length coords)3) coords)))
(vlax-put ent 'coordinates coords)
)
(alert "Bad polyline")
)
)
(defun c:test ( / n ss coords ent)
(setq n -1)
(setq ss (ssget '((0 . "LWPOLYLINE"))))
(repeat (sslength ss)
(setq ent (ssname ss (setq n (1+ n))))
(delpa ent)
)
)
I've tried to use chatgpt to generate some, but none of them worked.
This is a real false good idea, this is false advertising this AI
let me know if that’s right, please
Amicalement