Author Topic: How to select all lines based on the angle?  (Read 329 times)

0 Members and 1 Guest are viewing this topic.

teslaxx

  • Mosquito
  • Posts: 2
How to select all lines based on the angle?
« on: March 26, 2021, 08:07:47 AM »
Hello!

I would like to delete all lines in a Autocad File based on a filter: the angle of the line.

I found the qselect command and it's very useful, but it doesn't search on all layouts

What would be my options regarding this?

Stefan

  • Bull Frog
  • Posts: 253
Re: How to select all lines based on the angle?
« Reply #1 on: March 26, 2021, 10:30:57 AM »
Welcome to the swamp

No native function ready to use and no dxf filters available for this task. You have to build your own function.
Select all lines, iterate the selection and eliminate the ones that doesn't match the required angle.

Something like this for creating the selection (with a minimum effort you can edit the lisp to delete them):

Code - Auto/Visual Lisp: [Select]
  1. ;select lines by angle
  2. ;Stefan M. 26.03.2021
  3. (defun c:ssla ( / get_line_angle e ss i a)
  4.  
  5.   (defun get_line_angle (e / p1 p2 a)
  6.     (setq e (entget e)
  7.           p1 (cdr (assoc 10 e))
  8.           p2 (cdr (assoc 11 e))
  9.           a  (angle p1 p2)
  10.     )
  11.     ;return
  12.     ;a ; for exact match (0 /= 180)
  13.     (atan (/ (sin a) (cos a))) ; for visual match (0 = 180)
  14.   )
  15.  
  16.   (ssget "_I")
  17.   (sssetfirst nil nil)
  18.  
  19.   (if
  20.     (and
  21.       (setq e (car (entsel "\nSelect line to match angle: ")))
  22.       (setq ss (ssget "_X" '((0 . "LINE"))))
  23.     )
  24.     (progn
  25.       (setq a (get_line_angle e))
  26.       (repeat (setq i (sslength ss))
  27.         (setq i (1- i)
  28.               e (ssname ss i)
  29.         )
  30.         (or
  31.           (equal a (get_line_angle e) 1e-6)
  32.           (ssdel e ss)
  33.         )
  34.       )
  35.       (sssetfirst nil ss)
  36.     )
  37.   )
  38.  
  39.   (princ)
  40. )
  41.  

teslaxx

  • Mosquito
  • Posts: 2
Re: How to select all lines based on the angle?
« Reply #2 on: March 29, 2021, 02:05:16 AM »
Thank you a lot for your help, but, it still doesn't select the lines on ALL LAYOUT, only the current layout. It probably need just an additional line.

Stefan

  • Bull Frog
  • Posts: 253
Re: How to select all lines based on the angle?
« Reply #3 on: March 29, 2021, 09:56:12 AM »
It does select from all Layouts, but if you use any native Autocad command on the selection, only the objects in the current space are processed.
You need to program your command to work on all objects.
If you want to delete them, ERASE is not working, (entdel <ename>) is not working, but (vla-delete <vla-object>) will do the trick.