TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lee Mac on September 21, 2009, 06:42:05 AM
-
I've been trying to collect items in Rows/Columns, with a fuzz factor, but can't seem to get the ssget list to function as I expected.
The user should pick 1 item in the row/column, and everything in the row/column should be highlighted.
Here is what I have been trying:
(defun c:getblocks (/ ent rot pt)
(vl-load-com)
(if (setq ent (ssget "_:S:E" '((0 . "INSERT") (66 . 1))))
(progn
(setq ent (ssname ent 0) rot (dxf 50 ent) pt (dxf 10 ent))
(sssetfirst nil
(ssget "_X" (list '(0 . "INSERT")
(cond ( (or (equal pi rot 0.01) (equal 0. rot 0.01))
'(-4 . "*,<=,*")
(cons 10 (list 0. (+ (cadr pt) 100.) 0.))
'(-4 . "*,=>,*")
(cons 10 (list 0. (- (cadr pt) 100.) 0.)))
( (or (equal (/ pi 2.) rot 0.01) (equal (* 3 (/ pi 2.)) rot 0.01))
'(-4 . "<=,*,*")
(cons 10 (list (+ (car pt) 100.) 0. 0.))
'(-4 . "=>,*,*")
(cons 10 (list (- (car pt) 100.) 0. 0.)))
(t '(-4 . "=,=,=")))
(assoc 10 (entget ent))
'(66 . 1))))))
(princ))
(defun dxf (code ent)
(cdr (assoc code (entget ent))))
Any help is appreciated.
Lee
-
Here is an old example, maybe it will help.
=======================================================================
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))
)
============================================================
-
Ahhh... schoolboy error!
It was obviously only taking the last return of the COND statement, so the -4 wasn't being included!
Thanks for the example though CAB - much appreciated. :-)