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

Need to reduce a poliline with multiple vertices to a single polyline

4 REPLIES 4
Reply
Message 1 of 5
richie_hodgson
807 Views, 4 Replies

Need to reduce a poliline with multiple vertices to a single polyline

Hi

 

I would like to take all the vertices out of a multiple-vertices polyline so that it reduces to just its start and end points, can this be done?

Richie
4 REPLIES 4
Message 2 of 5
_Tharwat
in reply to: richie_hodgson

This..... ?

 

(defun c:Test (/ ss i sn l p)
  (if (setq ss (ssget "_:L" '((0 . "*POLYLINE"))))
    (repeat (setq i (sslength ss))
      (setq sn (ssname ss (setq i (1- i))))
      (setq
        l (vl-remove-if-not
            (function
              (lambda (x) (member (car x) '(0 100 8 70 90 410 210)))
            )
            (entget sn)
          )
      )
      (setq p (vl-remove-if-not
                (function (lambda (x) (eq (car x) 10)))
                (entget sn)
              )
      )
      (entmakex (append l (list (car p) (last p))))
      (entdel sn)
    )
  )
  (princ)
)

 

Message 3 of 5

Perfect thanks

Richie
Message 4 of 5
_Tharwat
in reply to: richie_hodgson


@richie_hodgson wrote:

Perfect thanks



You're welcome .

Message 5 of 5


@richie_hodgson wrote:

.... 

I would like to take all the vertices out of a multiple-vertices polyline so that it reduces to just its start and end points, ....


Another way, straightening the Polyline from start to end, if 'ename' is the entity name of the Polyline:

 

(command "_.pedit" ename "_e" "_s")
(repeat (1- (cdr (assoc 90 (entget ename))))
  (command "")
); repeat
(command "_g" "_x" "")

 

And another, that depends on the fact that if not given 40/41/42 values for widths and bulge after vertex locations, it will assume zero for all of them:

 

(setq edata (entget ename))
(entmake
  (append
    (vl-remove-if '(lambda (x) (member (car x) '(10 40 41 42))) edata); all except vertices/widths/bulges
    (list (assoc 10 edata)); first vertex
    (list (assoc 10 (reverse edata))); last vertex
  )
)
(entdel ename)

 

And another:

 

(command
  "_.pline"
  (vlax-curve-getStartPoint ename)
  (vlax-curve-getEndPoint ename)
  ""
  "_.matchprop" ename "_last" ""
  "_.erase" ename ""
)

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost