Does anyone know of a routine the can select or highlight lines in a drawing that have a Delta X or Delta Y that is not zero out to 7 or 8 decimal places?
Thanks,
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Try like this
(ssget "X" (list (cons 0 "LINE") (cons -4 "<AND") (cons -4 "*,*,<") (cons 10 (list 0.0 0.0 1e-09)) (cons -4 "*,*,<") (cons 11 (list 0.0 0.0 1e-09)) (cons -4 "AND>") ) ) ;;;OR: (ssget "X" (list '(0 . "line") '(-4 . "<and") '(-4 . "*,*,<") (cons 10 (list 0.0 0.0 1e-09)) '(-4 . "*,*,<") (cons 11 (list 0.0 0.0 1e-09)) '(-4 . "and>") ) )
not tested absolutely
Hi Hallex,
Thanks for the reply. I rewrote the routine as:
(defun c:notst ()
(ssget "X"
(list (cons 0 "LINE")
(cons -4 "<AND")
(cons -4 "*,*,<")
(cons 10 (list 0.0 0.0 1e-09))
(cons -4 "*,*,<")
(cons 11 (list 0.0 0.0 1e-09))
(cons -4 "AND>")
)
)
(command "select" "p" "")
)
But it isn't quite working. In a drawing with a few entities, I load and run the routine (without the (command "select" "p" "") line and it returns "<Selection set: 7d9>" at the command line.but nothing is selected. If I enter the command string Select > Previous > Enter, it selects all of the lines in the drawing and not just the lines that are not horizontal (Delta Y = 0) or vertical (Delta X = 0). With the (command "select" "p" "") line added, the routine returns nil.
Any suggestions?
Something like this perhaps.
(defun c:test ( / ENT HND I SS SS1) (if (setq ss (ssget "_X" '((0 . "LINE")))) (progn (setq ss1 (ssadd)) (repeat (setq i (sslength ss)) (setq hnd (ssname ss (setq i (1- i))) ent (entget hnd) ) (if (and (not (equal (cadr (assoc 10 ent)) (cadr (assoc 11 ent)) 1e-9)) (not (equal (caddr (assoc 10 ent)) (caddr (assoc 11 ent)) 1e-9)) ) (ssadd hnd ss1) ) ) (sssetfirst nil ss1) ) ) (princ) )
HTH
Henrique
Perfect Henrique.
Thank you.
@jonmcfarlandWS wrote:
Does anyone know of a routine the can select or highlight lines in a drawing that have a Delta X or Delta Y that is not zero out to 7 or 8 decimal places?
....
Another way, that looks for Lines at angles not close enough to orthogonal, rather than for X or Y differences, because it can check both at once:
(if (setq ss (ssget "_X" '((0 . "LINE"))))
(progn
(repeat (setq inc (sslength ss))
(setq
ent (ssname ss (setq inc (1- inc)))
edata (entget ent)
); setq
(if (equal (rem (angle (cdr (assoc 10 edata)) (cdr (assoc 11 edata))) (/ pi 2)) 0.0 1e-8); is it orthogonal?
(ssdel ent ss); then -- remove it from set
); if
); repeat
(sssetfirst nil ss); those remaining, not orthogonal enough
); progn
); if
You might play with the size of the fuzz factor, since a difference in angle isn't the same as a difference in X/Y position.
When testing the remainder you would need to use:
(defun c:orthotest ( / a e i m s x ) (setq m (/ pi 2.0)) (if (setq s (ssget "_X" '((0 . "LINE")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) x (entget e) a (rem (angle (cdr (assoc 10 x)) (cdr (assoc 11 x))) m) ) (if (or (equal a 0.0 1e-8) (equal a m 1e-8)) (ssdel e s) ) ) ) (sssetfirst nil s) (princ) )
To account for plus/minus the tolerance.
Alternatively:
(defun c:orthotest ( / a e i s x ) (if (setq s (ssget "_X" '((0 . "LINE")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) x (entget e) a (angle (cdr (assoc 10 x)) (cdr (assoc 11 x))) ) (if (equal (sin (+ a a)) 0.0 1e-8) (ssdel e s) ) ) ) (sssetfirst nil s) (princ) )