============================================================================
Thread by Stig
http://www.theswamp.org/index.php?topic=1333.msg16766#msg16766
I don't blame you. Filtering by coordinates isn't seen all that often but it is
built into SSGET. You need a relational test looking something like this:
(setq sset (ssget "X" '((-4 . "*,*,>=")(10 0.0 0.0 10.0))))
^this will filter all entities with a group 10 point that has Z greater than or
equal to 10.0
The relational test for each coordinate is separated by commas in the -4 group
and the point is simply given as it appears in the entity list, except each
coordinate is a criterion.
If you need to filter more point groups, you need to provide more -4 groups. For
example, to filter both group 10 and 11:
(setq sset (ssget "X" '((-4 . "*,*,>=")(10 0.0 0.0 10.0)(-4 . "*,*,>")(11 0.0 0.0 10.0))))
=======================================================================
CAB 03.29.08
get any nornal that is not 0 0 1
(setq ss (ssget "X" '((-4 . "<NOT")(210 0.0 0.0 1.0)(-4 . "NOT>")(-4 . "*,*,*")(210 0.0 0.0 1.0))))
=======================================================================
Example by CAB
Find a circle with a given center point
If the center point of the circle & the start point of the plines are the same this will get them.
(setq mdn (ssget "x" (list '(0 . "circle") (append '(10) stp))) )
If you need some wiggle room try this: [ignoring the z]
(setq wiggle 0.05)
(setq mdn (ssget "x" (list '(0 . "circle")
'(-4 . ">,*,*") (list 10 (- (car stp) wiggle) 0 0)
'(-4 . "<,*,*") (list 10 (+ (car stp) wiggle) 0 0)
'(-4 . "*,>,*") (list 10 0 (- (cadr stp) wiggle) 0)
'(-4 . "*,<,*") (list 10 0 (+ (cadr stp) wiggle) 0)
) )
)
Reads like this:
(if (and (> (center x) (- (pt x) wiggle))
(< (center x) (+ (pt x) wiggle))
(> (center y) (- (pt y) wiggle))
(< (center y) (+ (pt y) wiggle))
)
===============================
(ssget "x" '((50 . 3.14159))) ; need to catch rounding errors
use
(ssget "x" '((-4 . ">") (50 . 3.14158)(-4 . "<") (50 . 3.14160)))
=============================
Example by Luis uses a list of points
(setq filter (append (list '(-4 . "<AND") '(0 . "AECC_POINT") '(-4 . "<OR"))
(mapcar (function (lambda (x) (cons 90 x)))
num_list
)
(list '(-4 . "OR>") '(-4 . "AND>"))
)
)
(ssget "X" filter)
============================================================
(OR (*.00000000) (*.25000000) (*.50000000) (*.75000000))
(defun c:fe (/ ss i ent elst dxf10 dxf11 dxfx dxfy)
(if (setq ss (ssget (list '(0 . "TEXT") (cons 410 (getvar "ctab"))))) ; current space only
(progn
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq elst (entget ent)
dxf10 (cdr (assoc 10 elst))
dxfx (rem (car dxf10) 1) ; get fraction only, remove hole number
dxfy (rem (cadr dxf10) 1)
dxf11 (cdr (assoc 11 elst)) ; this if text is not LEFT justified
)
(if (not (equal '(11 0.0 0.0 0.0) dxf11))
(setq dxfx (rem (car dxf11) 1)
dxfy (rem (cadr dxf11) 1)
)
)
(if (or (vl-some (function (lambda (x) (equal x dxfx 0.00001))) '(0.0 0.25 0.5 0.75))
(vl-some (function (lambda (x) (equal x dxfy 0.00001))) '(0.0 0.25 0.5 0.75)))
(entmakex
(list (cons 0 "CIRCLE")
(cons 6 "BYLAYER")
;; (cons 8 "0") ; layer
(cons 10 (list dxfx dxfy 0.0))
(cons 39 0.0)
(cons 40 0.75) ; radius
(cons 62 256)
(cons 210 (list 0.0 0.0 1.0))
)
)
)
)
)
(princ "There are no text entity containing your search !")
)
)
Code: [Select](setq dxfx (rem (car dxf11) 1)
dxfy (rem (cadr dxf11) 1)
)
...
(if (or (vl-some (function (lambda (x) (equal x dxfx 0.00001))) '(0.0 0.25 0.5 0.75))
(vl-some (function (lambda (x) (equal x dxfy 0.00001))) '(0.0 0.25 0.5 0.75)))
I am looking for x and y where the fraction = *.00000000 or *.25000000 or *.50000000 or *.75000000
(defun c:fe (/ ss i ent elst dxf10 dxf11 dxfx dxfy)
(if (setq ss (ssget (list '(0 . "TEXT")))) ; current space only
(progn
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq elst (entget ent)
dxf10 (cdr (assoc 10 elst))
dxfx (rem (car dxf10) 1) ; get fraction only, remove hole number
dxfy (rem (cadr dxf10) 1)
dxf11 (cdr (assoc 11 elst)) ; this if text is not LEFT justified
)
(if (not (equal '(0.0 0.0 0.0) dxf11))
(setq dxfx (rem (car dxf11) 1)
dxfy (rem (cadr dxf11) 1)
)
)
(if (or (not(vl-some (function (lambda (x) (equal x dxfx 0.001))) '(0.0 0.25 0.5 0.75 1.0)))
(not(vl-some (function (lambda (x) (equal x dxfy 0.001))) '(0.0 0.25 0.5 0.75 1.0))))
(entmakex
(list (cons 0 "CIRCLE")
(cons 6 "BYLAYER")
(cons 8 "0") ; layer
(assoc 10 elst)
(cons 39 0.0)
(cons 40 0.75) ; radius
(cons 62 256)
(cons 210 (list 0.0 0.0 1.0))
)
)
)
)
)
(princ "There are no text entity containing your search !")
)
)
(defun c:fe (/ ss i ent elst dxf10 dxf11 dxfx dxfy fuzz)
(setq fuzz 0.01)
(if (setq ss (ssget (list '(0 . "TEXT"))))
(progn
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq elst (entget ent)
dxf10 (cdr (assoc 10 elst))
dxfx (rem (car dxf10) 1) ; get fraction only, remove hole number
dxfy (rem (cadr dxf10) 1)
dxf11 (cdr (assoc 11 elst)) ; this if text is not LEFT justified
)
(if (not (equal '(0.0 0.0 0.0) dxf11))
(setq dxfx (rem (car dxf11) 1)
dxfy (rem (cadr dxf11) 1)
)
)
(if (or (not(vl-some (function (lambda (x) (equal x dxfx fuzz))) '(0.0 0.25 0.5 0.75 1.0)))
(not(vl-some (function (lambda (x) (equal x dxfy fuzz))) '(0.0 0.25 0.5 0.75 1.0))))
(entmakex
(list (cons 0 "CIRCLE")
(cons 6 "BYLAYER")
(cons 8 "0") ; layer
(assoc 10 elst)
(cons 39 0.0)
(cons 40 0.75) ; radius
(cons 62 256)
(cons 210 (list 0.0 0.0 1.0))
)
)
)
)
)
(princ "There are no text entity containing your search !")
)
)
(defun c:test()
(setq ent (car(entsel))
elst (entget ent)
dxf10 (assoc 10 elst))
(princ (strcat(rtos (cadr dxf10) 2 10)" "(rtos (caddr dxf10) 2 10)" "(rtos (cadddr dxf10) 2 10)))
(princ)
)
Are you wanting to move the text to the exact location if they are not perfect?(defun c:fe (/ ss i ent elst dxf10 dxf11 dxfx dxfy fuzz)
(setq fuzz 0.00001)
; By MP
(defun round (number by)
(if (zerop by)
number
(+ (* (fix (/ number (setq by (abs by)))) by)
(if (< (* 0.5 by) (rem number by))
by
0
)
)
)
)
(defun myround (r) (* (round (/ r 0.25) 1.) 0.25))
(if (setq ss (ssget (list '(0 . "TEXT") '(72 . 0))))
(progn
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq elst (entget ent)
dxf10 (assoc 10 elst)
dxfx (rem (cadr dxf10) 1) ; get fraction only, remove hole number
dxfy (rem (caddr dxf10) 1)
)
(if (or (not (vl-some (function (lambda (x) (equal x dxfx fuzz))) '(0.0 0.25 0.5 0.75 1.0)))
(not (vl-some (function (lambda (x) (equal x dxfy fuzz))) '(0.0 0.25 0.5 0.75 1.0)))
)
(progn
(setq newpoint (list 10 (myround (cadr dxf10)) (myround (caddr dxf10)) 0.0))
(entmod (subst newpoint dxf10 elst))
(entmakex
(list (cons 0 "CIRCLE")
(cons 6 "BYLAYER")
(cons 8 "0") ; layer
(assoc 10 elst)
(cons 39 0.0)
(cons 40 0.75) ; radius
(cons 62 256)
(cons 210 (list 0.0 0.0 1.0))
)
)
)
)
)
)
(princ "There are no text entity containing your search !")
)
)