Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to select a segment from a polyline and remove it ?

1 REPLY 1
Reply
Message 1 of 2
loloster
338 Views, 1 Reply

How to select a segment from a polyline and remove it ?

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))
)
)
1 REPLY 1
Message 2 of 2
loloster
in reply to: loloster

mm here a quick and dirty way of handling arc segments...

(defun drop1+3(item lst)
;;remove an item in a list and the folowing three...
(append (reverse (cdr (member item (reverse lst))))
(cdr(cdr(cdr(cdr (member item lst)))))
)
)

.. in code below change the call to "drop" routine by a call to
"drop1+3" instead

HTH

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost