+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Super Member chrisdarmanin's Avatar
    Using
    AutoCAD 2009
    Join Date
    Feb 2006
    Location
    Malta
    Posts
    524

    Default Simple lisp request please :)

    Registered forum members do not see this ad.

    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
    Quote by George (AWDC Malta President) about Land Rovers:
    "Trid ittiha xebgħa mazza ta' bla raġuni"
    Translation: You have to attack it with a mallet for no reason at all"

  2. #2
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    6,040

    Default

    Quote Originally Posted by chrisdarmanin View Post
    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.

    Code:
    ;;; 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
    Last edited by alanjt; 15th Sep 2009 at 01:53 pm.
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  3. #3
    Super Member chrisdarmanin's Avatar
    Using
    AutoCAD 2009
    Join Date
    Feb 2006
    Location
    Malta
    Posts
    524

    Default

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

    (because it needs to do that)
    Quote by George (AWDC Malta President) about Land Rovers:
    "Trid ittiha xebgħa mazza ta' bla raġuni"
    Translation: You have to attack it with a mallet for no reason at all"

  4. #4
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    6,040

    Default

    Quote Originally Posted by chrisdarmanin View Post
    hmmm.... it doesnt seem to switch on those that are off......

    (because it needs to do that)
    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.
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  5. #5
    Super Member chrisdarmanin's Avatar
    Using
    AutoCAD 2009
    Join Date
    Feb 2006
    Location
    Malta
    Posts
    524

    Default

    i'll try again on another drawing later.... busy at work at the moment.... btw have you managed to get some sleep?
    Quote by George (AWDC Malta President) about Land Rovers:
    "Trid ittiha xebgħa mazza ta' bla raġuni"
    Translation: You have to attack it with a mallet for no reason at all"

  6. #6
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    6,040

    Default

    Quote Originally Posted by chrisdarmanin View Post
    i'll try again on another drawing later.... busy at work at the moment.... btw have you managed to get some sleep?
    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.
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  7. #7
    Super Member chrisdarmanin's Avatar
    Using
    AutoCAD 2009
    Join Date
    Feb 2006
    Location
    Malta
    Posts
    524

    Default

    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
    Quote by George (AWDC Malta President) about Land Rovers:
    "Trid ittiha xebgħa mazza ta' bla raġuni"
    Translation: You have to attack it with a mallet for no reason at all"

  8. #8
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    6,040

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by chrisdarmanin View Post
    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):
    Code:
        ;; 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
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

Similar Threads

  1. Lisp file request
    By Stryder in forum AutoLISP, Visual LISP & DCL
    Replies: 65
    Last Post: 13th Oct 2009, 09:40 pm
  2. Wall LISP Request.
    By TheNewGuy in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 9th Jun 2009, 05:23 am
  3. LISP Request - Elevations
    By Bill Tillman in forum AutoLISP, Visual LISP & DCL
    Replies: 22
    Last Post: 23rd Apr 2009, 04:25 pm
  4. A lisp request
    By Joro-- in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 1st Apr 2007, 02:24 pm
  5. Request for Lisp
    By aledtaylor in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 21st Dec 2005, 04:01 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts