TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: V-Man on October 14, 2008, 10:18:35 AM
-
A little assistance needed here. I am trying to get this to check for any items on Layer 0 and omit the Viewport and report back to the use if any found besides the Viewport back to the user via Alert. Can someone shed some light on this or is there a better way?
(defun chk_layer_0 (/ ss)
(princ "\nChecking for objects on layer 0")
(if (setq ss (ssget "x" '((8 . "0"))))
(if (= 1 (sslength ss))
(if (and (= "VIEWPORT" (cdr (assoc 0 (entget (ssname ss 0)))))
(= 1 (cdr (assoc 69 (entget (ssname ss 0)))))
)
(progn
(princ "\nNo objects found on layer 0.")
) ;end progn
(progn
(princ (strcat "\nLocated "
(itoa (sslength ss))
" objects on layer 0."
)
)
)
)
)
)
(progn
(princ "\nNo objects found on layer 0.")
)
)
Thanks,
Don
-
How about something like this:
(defun chk_layer_0 (/ ss)
(if (setq ss (ssget "x"
'((8 . "0") (-4 . "<NOT") (0 . "VIEWPORT") (-4 . "NOT>"))
)
)
(progn
(princ (strcat "\nLocated "
(itoa (sslength ss))
" objects on layer 0."
)
)
(sssetfirst nil ss)
)
(princ "\nNo objects found on layer 0.")
)
(princ)
)
(chk_layer_0)
-
Nice Ron but it does pick up VPs from clipped or converted viewports because there is an object associated with that VP.
-
Nice Ron but it does pick up VPs from clipped or converted viewports because there is an object associated with that VP.
Picky picky picky :-P
*edit...from my tests it does not select any viewports? It will select the object associated with the VP if it is on layer 0.
-
Picky picky picky :-P
:-D
That's right but that object is part of the VP definition in my mind.
A CIRCLE VP has a circle entity associated with it and I suspect should be ignored.
Just my openion. 8-)
-
Objects within blocks on layer 0 are intentionally ignored?
-
Objects within blocks on layer 0 are intentionally ignored?
I would think so? All of our blocks are intentionally created with objects on layer 0 so they will inherit the layer color they are placed on.
-
Modified version to ignore VP related objects.
(defun chk_layer_0 (/ ss ename elist vptest removelist)
(if (setq ss (ssget "x" '((8 . "0")(0 . "~VIEWPORT"))))
(progn
(setq i -1)
(while (setq ename (ssname ss (setq i (1+ i))))
(setq elist (entget ename))
(if (and
(setq vptest (member '(102 . "{ACAD_REACTORS") elist))
(setq vptest (member '(102 . "}") (reverse vptest)))
(assoc 330 vptest)
)
(setq removelist (cons ename removelist))
)
)
(mapcar '(lambda (x) (ssdel x ss)) removelist)
(if (and ss (> (sslength ss) 0))
(progn
(princ (strcat "\nLocated "
(itoa (sslength ss))
" objects on layer 0."
)
)
(sssetfirst nil ss)
)
)
)
(princ "\nNo objects found on layer 0.")
)
(princ)
)
-
Nice CAB...forgot about the ~ in the filter 8-)
Question...would this work as well?
'((8 . "0")
(-4 . "<NOT")
(102 . "{ACAD_REACTORS")
(-4 . "NOT>")
(0 . "~VIEWPORT")
)
-
Some other object may have an ACAD reactor. Not sure which ones but wouldn't want to bet on it.