Erasing lines of same angle LISP

Erasing lines of same angle LISP

christian.ekstromSXBY8
Observer Observer
232 Views
2 Replies
Message 1 of 3

Erasing lines of same angle LISP

christian.ekstromSXBY8
Observer
Observer

Hi!

 

Trying to work out a way to select and erase lines/polylines of the same angle, for example an exploded hatch.

 

I found this old LISP routine from 2008, but I can't get it to work. When apploading it returns: 

 

too few arguments in SETQ: (SETQ LINEDATA (ENTGET (CAR (ENTSEL "\nSelect Line at angle of those to be removed:\n"))) ANG1 (ANGLE (CDR (ASSOC 10 LINEDATA)) (CDR (ASSOC 11 LINEDATA))) ANG2 (IF (>= ANG1 PI) (- ANG1 PI) (+ ANG1 PI)) LINESET (SSGET "_X" (QUOTE ((0 . "LINE")))) ANGSET (SSADD) SELECTION SET OF LINES AT THAT ANGLE).

 

(defun c:ANGLEDEL (/ linedata ang1 ang2 lineset
angset edata eang)
  (setq
    linedata (entget (car
(entsel "\nSelect Line at angle of those to be removed:
")))
    ang1 (angle (cdr (assoc 10 linedata)) (cdr (assoc 11
linedata)))
    ang2 (if (>= ang1 pi) (- ang1 pi) (+ ang1
pi)); opposite direction too
    lineset (ssget "_X" '((0 .
"LINE"))); gather all Lines
    angset (ssadd); base for
selection set of Lines at that angle
  ); end setq
  (while
(> (sslength lineset) 0)
   
(setq
      edata (entget (ssname lineset 0)); get
data about first Line in set
      eang (angle (cdr
(assoc 10 edata)) (cdr (assoc 11 edata))); get its angle
   
); end setq
    (if (or (equal eang ang1 0.001) (equal eang
ang2 0.001)); if it runs in the right
direction
      (ssadd (ssname lineset 0) angset);
put it in the set of Lines at that angle
    ); end
if
    (ssdel (ssname lineset 0) lineset); take it out of the
set of all Lines
  ); end while - go back and check the next
one
  (command "_.erase" angset)
); end defun

 

 

0 Likes
Accepted solutions (1)
233 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

Mostly needs to be re-formatted as line breaks were added where they shouldn't be.

 

(defun c:ANGLEDEL (/ linedata ang1 ang2 lineset angset edata eang)
  
  (setq linedata (entget (car (entsel "\nSelect Line at angle of those to be removed: ")))
	ang1 (angle (cdr (assoc 10 linedata)) (cdr (assoc 11 linedata)))
	ang2 (if (>= ang1 pi) (- ang1 pi) (+ ang1 pi)); opposite direction too
	lineset (ssget "_X" '((0 . "LINE"))); gather all Lines
	angset (ssadd); base for     selection set of Lines at that angle
	); end setq
  (while (> (sslength lineset) 0)
    
    (setq
      edata (entget (ssname lineset 0)); get
      data about first Line in set
      eang (angle (cdr (assoc 10 edata)) (cdr (assoc 11 edata))); get its angle
      
      ); end setq
    (if (or (equal eang ang1 0.001) (equal eang ang2 0.001)); if it runs in the right       direction
      (ssadd (ssname lineset 0) angset);       put it in the set of Lines at that angle
      ); end     if
    (ssdel (ssname lineset 0) lineset); take it out of the     set of all Lines
    ); end while - go back and check the next   one
  (command "_.erase" angset "")
  (princ)
  ); end defun

 

Message 3 of 3

christian.ekstromSXBY8
Observer
Observer

Thank you so much! Worked like a charm!😊

0 Likes