Code Red > AutoLISP (Vanilla / Visual)
Set 'NoPlot' of selected objects' Layers
keebo:
Thanks Lee & John. All very useful information that I'm sure will come in handy going forward.
rkmcswain:
--- Quote from: Lee Mac on January 15, 2020, 01:48:58 PM ---FWIW, note that you needn't necessarily stray into Visual LISP & ActiveX to accomplish this - here is an example using Vanilla AutoLISP:
--- Code - Auto/Visual Lisp: ---(defun c:test ( / e x ) (while (setq e (car (nentsel "\nSelect object whose layer should not be plotted: "))) (setq x (entget (tblobjname "layer" (cdr (assoc 8 (entget e)))))) (entmod (subst '(290 . 0) (assoc 290 x) x)) ) (princ))
--- End quote ---
Nice @LeeMac
Lee Mac:
Thanks :-)
JohnK:
Playing around waiting for an email. Not tested.
--- Code - Auto/Visual Lisp: ---(defun ent-layer-to-no-plot ( ent ) (cond ( (null ent) (ent-layer-to-no-plot (car (nentsel (strcat "\nSelect an object: "))))) ( (eq (type ent) 'ENAME) (ent-layer-to-no-plot (entget (tblobjname "layer" (cdr (assoc 8 (entget ent))))))) ( (eq (type ent) 'LIST) (entmod (subst '(290 . 0) (assoc 290 ent) ent))) ) (princ) )(ent-layer-to-no-plot nil)
JohnK:
A day later--AutoCAD installed--and I gave my function above a quick test. It works (yay!).
Aside: I had a few minutes in between tasks yesterday and this thread was in my unread feed so I picked a mini challenge for myself in creating a function with no variables. Recursion was a simple solution to this but I thought I'd mention that this function is no more "efficient/smaller/etc." then one that does (assuming that a function that creates variables cleans up after itself).
Navigation
[0] Message Index
[*] Previous page
Go to full version