Author Topic: Layer Lisp question  (Read 3354 times)

0 Members and 1 Guest are viewing this topic.

One Shot

  • Guest
Layer Lisp question
« on: February 17, 2005, 04:14:24 PM »
:?: Is there a lisp routine that can turn on just layers of an active session.   I don't think that I expalined my self correct.  What I whant to do is to turn on all layers except for the laeyers that are associated to Xrefs?



Thank you,

Brad

whdjr

  • Guest
Layer Lisp question
« Reply #1 on: February 17, 2005, 04:46:40 PM »
In the layers dialog box is a built-in filter for all xrefs.

sinc

  • Guest
Layer Lisp question
« Reply #2 on: February 17, 2005, 04:47:45 PM »
Do you really need to do that in Lisp?  Why not just change it in the Layer Manager?  Use the "Show All XRef Dependent Layers" layer filter, and invert the filter.  Then select all and change whatever you want.

whdjr

  • Guest
Layer Lisp question
« Reply #3 on: February 17, 2005, 04:55:17 PM »
oops...I forgot about inverting the selection, but sinc picked it up for me.

Thanks sinc :?

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Layer Lisp question
« Reply #4 on: February 17, 2005, 05:34:32 PM »
Well, here's something you can call from a button or the command line that eliminates the need for the time consuming Layer dialog:
Code: [Select]

(defun c:off-xr ()
  (command "-layer" "on" "*" "off" "*|*" "")
  (princ)
  )

One Shot

  • Guest
Layer Lisp question
« Reply #5 on: February 17, 2005, 05:47:35 PM »
Quote from: Jeff_M
Well, here's something you can call from a button or the command line that eliminates the need for the time consuming Layer dialog:
Code: [Select]

(defun c:off-xr ()
  (command "-layer" "on" "*" "off" "*|*" "")
  (princ)
  )


Thank you,

that works great.

What I need is to have the Xref layers that are off to stay off and the rest of the drawing turn on.

whdjr

  • Guest
Layer Lisp question
« Reply #6 on: February 17, 2005, 05:57:13 PM »
If you have the Expresstools use:

LAYOFF
LAYON
LAYFRZ
LAYTHW
 :)

One Shot

  • Guest
Layer Lisp question
« Reply #7 on: February 17, 2005, 06:06:55 PM »
Quote from: whdjr
If you have the Expresstools use:

LAYOFF
LAYON
LAYFRZ
LAYTHW
 :)


I know about the Expresstool.  But it still does not do what I want to do.

whdjr

  • Guest
Layer Lisp question
« Reply #8 on: February 17, 2005, 06:15:02 PM »
Sorry...that's the second time I have miss read THIS thread. :?  :shock:  :oops:

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Layer Lisp question
« Reply #9 on: February 17, 2005, 06:23:11 PM »
In my opinion all you need to do is learn how to use wildcards:

To turn on all layers that are not xrefs (command line):

-layer[enter]
on[enter]
~*|*[enter][enter]

However, in the spirit of swamp helpfulness a quick and dirty ...

Code: [Select]
(defun TurnLayersOnOff ( spec onIsNotNil / state clayer name )
    (if
        (eq :vlax-false
            (setq state
                (if onIsNotNil
                    :vlax-true
                    :vlax-false
                )
            )    
        )    
        (setq clayer (getvar "clayer"))
    )
    (setq spec (strcase spec))
    (vlax-for layer
        (vlax-get-property
            (vlax-get-property
                (vlax-get-acad-object)
               'ActiveDocument
            )
           'Layers
        )
        (if
            (wcmatch
                (setq name
                    (strcase
                        (vlax-get-property
                            layer
                           'Name
                        )
                    )    
                )
                spec
            )
            (if clayer
                (if (eq clayer name)
                    (setq clayer nil)
                    (vlax-put-property
                        layer
                       'LayerOn            
                        state
                    )
                )    
                (vlax-put-property
                    layer
                   'LayerOn            
                    state
                )
            )    
        )    
    )    
    (princ)
)

Still requires knowledge of wildcards for effective use, but now you can precan some stuff on menus ad nauseum.

Some examples ...

;;  all layers off
(TurnLayersOnOff "*" nil)

;;  all layers on
(TurnLayersOnOff "*" t)

;;  all xref layers off
(TurnLayersOnOff "*|*" nil)

;;  all xref layers on
(TurnLayersOnOff "*|*" t)

;;  all non xref layers off
(TurnLayersOnOff "~*|*" nil)

;;  all non xrefs layers on
(TurnLayersOnOff "~*|*" t)

etc.

:D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

hudster

  • Gator
  • Posts: 2848
Layer Lisp question
« Reply #10 on: February 18, 2005, 03:58:37 AM »
Maybe you could adapt this routine

Code: [Select]
;;Multi services layer freeze routing
;;By Andy Hudson
;;Adapted from original code by Ronjop
;;Posted on www.theswamp.org
;;;
(defun C:MULTI (/ cmd att clay p)
  ;;GET USER VARIABLES
  (setq cmd  (getvar 'cmdecho)
att  (getvar 'attdia)
clay (getvar 'clayer))
  ;;SET LAYER TO ZERO
  (COMMAND "-LAYER" "THAW" "0" "SET" "0" "" "")
  (setvar 'cmdecho 0)
  (setvar 'attdia 1)
  ;;Set the drawing series numbers allowed
  (initget 0 "62 63 64 65 66 FA SEC 1")
  (setq P (cond ((getkword "\nEnter Drawing Series: 62 63 64 65 66 FA SEC <<Enter for all layers>>: "))
("1")))
  ;;All layers on
    (if (= P "1")
      (progn (command ".-layer" "thaw" "*" "")))
  ;;62 SERIES only
        (if (= P "62")
      (progn (command ".-layer" "t" "*62*" "F" "*63*" "F" "*64*" "F" "*65*" "F" "*66*" "F" "*68*" "F" "*95*" "F" "*96*" "T" "*DADO*" "")))
  ;;63 SERIES only
        (if (= P "63")
      (progn (command ".-layer" "t" "*63*""F" "*62*" "F" "*64*" "F" "*65*" "F" "*66*" "F" "*68*" "")))
  ;;64 SERIES only
        (if (= P "64")
      (progn (command ".-layer" "t" "*64*" "F" "*62*" "F" "*63*" "F" "*65*" "F" "*66*" "F" "*68*" "F" "*95*" "F" "*96*" "T" "*DADO*" "")))
  ;;65 SERIES only
    (if(= P "65")
      (progn (command ".-layer" "t" "*65*" "F" "*62*" "F" "*63*" "F" "*64*" "F" "*66*" "F" "*68*" "F" "*95*" "F" "*96*" "")))
  ;;66 SERIES only
        (if (= P "66")
      (progn (command ".-layer" "t" "*66*" "F" "*62*" "F" "*63*" "F" "*64*" "F" "*65*" "F" "*DADO*" "F" "*68*" "F" "*95*" "F" "*96*" "")))
  ;;68_FA SERIES only
        (if (= P "FA")
      (progn (command ".-layer" "t" "*68_FA*" "F" "*62*" "F" "*63*" "F" "*64*" "F" "*65*" "F" "*66*"  "F" "*68_SEC*" "F" "*95*" "F" "*96*" "")))
  ;;68_SEC SERIES only
        (if (= P "SEC")
      (progn (command ".-layer" "t" "*68_SEC*" "F" "*62*" "F" "*63*" "F" "*64*" "F" "*65*" "F" "*66*"  "F" "*68_FA*" "F" "*95*" "F" "*96*" "")))
  ;;;
  ;;RESET USER VARIABLES
  (setvar "cmdecho" cmd)
  (setvar "attdia" att)
  (setvar "clayer" clay)
  ;;CLEAN EXIT
  (princ)
  )
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

ronjonp

  • Needs a day job
  • Posts: 7529
Layer Lisp question
« Reply #11 on: February 18, 2005, 09:59:48 AM »
Quote
In my opinion all you need to do is learn how to use wildcards:

To turn on all layers that are not xrefs (command line):

-layer[enter]
on[enter]
~*|*[enter][enter]


Good stuff MP. I knew the *|* but didn't know about the ~.

So basically One Shot can get what he needs by:

Code: [Select]
^C^C.-layer;on;~*|*;thaw;~*|*;;

I learn something new every day here :D


Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC