TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Dommy2Hotty on September 09, 2005, 02:34:38 PM

Title: Layer States
Post by: Dommy2Hotty on September 09, 2005, 02:34:38 PM
1) Anyone have any insight as how to set a certain layer state with LISP?
2) Anyone have a multiple layer state delete utility?  Delteting them one by one sux.
Title: Re: Layer States
Post by: MP on September 09, 2005, 03:07:33 PM
;;  simple example, freeze all layers ...

Code: [Select]
(setq pattern "*")

(vlax-map-collection
    (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
   '(lambda ( layer )
        (if (wcmatch (vla-get-name layer) pattern)
            (vl-catch-all-apply
               '(lambda ()
                    (vla-put-freeze
                        layer
                       :vlax-true
                    )
                )
            )
        )
    )
)
Title: Re: Layer States
Post by: Jeff_M on September 09, 2005, 03:11:48 PM
1) Anyone have any insight as how to set a certain layer state with LISP?
2) Anyone have a multiple layer state delete utility?  Delteting them one by one sux.
This thread should get you what you need: Click Here (http://www.theswamp.org/forum/index.php?topic=763.msg12179#msg12179)
Title: Re: Layer States
Post by: Dommy2Hotty on September 09, 2005, 03:14:26 PM
I'm sorry...should have been more specific...

Express->Layers->Layer Manager...

Those layer states.  I want to make a plotting routine that will set the LTSCALE, and the set the Express Layer State (derived from the filename and CTAB variable).  I've got it all worked out, but I can't figure out how to set the Express Layer State.
Title: Re: Layer States
Post by: MP on September 09, 2005, 03:14:58 PM
Note to self: Read original question better.
Title: Re: Layer States
Post by: Dommy2Hotty on September 09, 2005, 03:15:11 PM
1) Anyone have any insight as how to set a certain layer state with LISP?
2) Anyone have a multiple layer state delete utility?  Delteting them one by one sux.
This thread should get you what you need: Click Here (http://www.theswamp.org/forum/index.php?topic=763.msg12179#msg12179)

Thanks Jeff...that's looks like it
Title: Re: Layer States
Post by: sourdough on September 10, 2005, 01:25:32 PM
1) Anyone have any insight as how to set a certain layer state with LISP?
2) Anyone have a multiple layer state delete utility?  Delteting them one by one sux.

Go to my post here it has alot of good info about layerstates I wrote and worked with others on. This should give you alot more to work with
to get what you want out of layerstates.

http://www.theswamp.org/forum/index.php?topic=5516.0

http://www.theswamp.org/forum/index.php?topic=5516.0

Mike
Title: Re: Layer States
Post by: Peter Jamtgaard on September 12, 2005, 05:49:30 PM
This should help.

I cooked it for one of my AU lectures a couple of years ago.
You might have to modify the version of autocad.

Peter Jamtgaard

Code: [Select]
(defun LSTATE (STATNAM / STATEOBJ)
 (vl-load-com)
 (if (= (substr (getvar "acadver") 1 2) "16")
  (setq STATEOBJ (vla-getinterfaceobject
                  (vlax-get-acad-object)
                  "autocad.acadlayerstatemanager.16"
                 )
  )
  (setq STATEOBJ (vla-getinterfaceobject
                  (vlax-get-acad-object)
                  "autocad.acadlayerstatemanager"
                 )
  )
 )
 (vla-SetDataBase STATEOBJ
                  (vla-get-database
                   (setq CDWGOBJ (vla-get-ActiveDocument
                                  (vlax-get-acad-object)
                                 )
                   )
                  )
 )
 (if (vl-catch-all-error-p
      (vl-catch-all-apply
      '(lambda (X)(vla-restore STATEOBJ X))
       (list STATNAM)
      )
     )     
  (princ "\nLayer state doesn't exist! :")
;  (vla-regen CDWGOBJ)
 )
 (princ)


Title: Re: Layer States
Post by: Dommy2Hotty on November 01, 2005, 12:49:00 PM
Peter...that works fantastically!  Except, I'm looking for the EXPRESS Layer states...as defined thru the LMAN command.  I tested with the LAYER command layer states, and it works great...however, all the drawings I want to use this on have the Express Layer States defined.