chrisdarmanin 发表于 2022-7-6 12:45:40

Simple lisp request please :)

is it possible for someone to make me a lisp to invert the layer status? (on/off, frozen/thawed)
 
what do you think? is it easy?
 
many thanks in advance

alanjt 发表于 2022-7-6 12:59:19

I'll be glad when this insomnia wears off, I'd like to go to bed.
This is a fairly easy task to accomplish. Definitely something anyone could accomplish with a little work.
 
Hope this helps.BTW, I think this can be accomplish in the layer manager, but I'm not sure, I never open it.
 

;;; Invert on/off and freeze/thaw state of all layers in drawing;;; Alan J. Thompson, 09.14.09(defun c:LayerInvert (/ #Doc) (vl-load-com) (vlax-for x (vla-get-Layers               (setq               #Doc (vla-get-activedocument (vlax-get-acad-object))               ) ;_ setq             ) ;_ vla-get-Layers   ;; invert on/off state   (vl-catch-all-apply   'vla-put-layeron   (list x         (if (eq (vla-get-layeron x) :vlax-true)             :vlax-false             :vlax-true         ) ;_ if   ) ;_ list   ) ;_ vl-catch-all-apply   ;; invert freeze/thaw state   (vl-catch-all-apply   'vla-put-freeze   (list x         (if (eq (vla-get-freeze x) :vlax-true)             :vlax-false             :vlax-true         ) ;_ if   ) ;_ list   ) ;_ vl-catch-all-apply ) ;_ vlax-for (vla-regen #Doc acActiveViewport) (princ)) ;_ defun

chrisdarmanin 发表于 2022-7-6 13:05:01

hmmm.... it doesnt seem to switch on those that are off......
 
(because it needs to do that)

alanjt 发表于 2022-7-6 13:19:37

Works fine for me. On->Off, Off->On, Frozen->Thawed, Thawed->Frozen
I even tested it on a file that has 730 layers (some even xrefed) with all assorted states. Everything was completely successful.

chrisdarmanin 发表于 2022-7-6 13:20:51

i'll try again on another drawing later.... busy at work at the moment.... btw have you managed to get some sleep?

alanjt 发表于 2022-7-6 13:29:16

Hope you get it to work. I'll give it another look tomorrow. Still no sleep, but I'm going to make another attempt at it.

chrisdarmanin 发表于 2022-7-6 13:44:58

i realised my problem now which is with my original question :S
 
can you remove the part where it inverts the freeze/thawed state because i was letting everything thawed so it froze everything....
 
my mistake sorry....
 
thanks again for your help

alanjt 发表于 2022-7-6 13:51:07

 
Easy fix, just remove this portion from the above code (I marked it in red):

    ;; invert freeze/thaw state   (vl-catch-all-apply   'vla-put-freeze   (list x         (if (eq (vla-get-freeze x) :vlax-true)             :vlax-false             :vlax-true         ) ;_ if   ) ;_ list   ) ;_ vl-catch-all-apply
页: [1]
查看完整版本: Simple lisp request please :)