Jump to content

Simple lisp request please :)


Recommended Posts

Posted

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

Posted
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

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
   [color=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[/color]
 ) ;_ vlax-for
 (vla-regen #Doc acActiveViewport)
 (princ)
) ;_ defun

Posted

hmmm.... it doesnt seem to switch on those that are off......

 

(because it needs to do that) :D

Posted
hmmm.... it doesnt seem to switch on those that are off......

 

(because it needs to do that) :D

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.

Posted

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

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

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.

Posted

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

Posted
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

 

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...