Jump to content

Toolbar to toggle layer on and off


Recommended Posts

i use section planes quite a bit and if you're familiar with planes than everytime you insert a new section plane the settings reset. i would like to insert into my template 3 section planes each with my custom settings one being for plan one being for front one being for side. each being on a seperate layer. i would like to create a macro along with a toolbar that toggles a particular layer on and off. how do i do this? using the same shortcut to turn the item both on and off? to toggle....

 

From what i can gather i think i need two seperate shortcuts for each layer one for on one for off. i would preffer not to do this if anyone can think of a better way

Link to comment
Share on other sites

With layers from lisp etc you can get the status of a layer its a number depends on combination of off on frozen locked, look for some layer lisps here with "assoc 70" in them should provide the answer.

Link to comment
Share on other sites

If you create two buttons on your palette you can assign the following command strings to turn the layer on or off:

 

^C^C_-layer;_on;"";;

^C^C_-layer;_off;"";;

Link to comment
Share on other sites

Have multiple turn ons but only need 1 turn off by pick object

 

Freeze or off its up to you its also a start for your is it on or off lisp

(DEFUN C:LF ()
 (setvar "cmdecho" 0)
 (SETQ DL (CDR (ASSOC 8 (ENTGET (CAR
 (ENTSEL "SELECT LAYER TO FREEZE: ")
 )))))
 (if (= dl (getvar "clayer"))(setvar "clayer" "0"))
 (COMMAND "layer" "f" dl "")
 (prompt "\n  LAYER FROZEN:  ")
 (EVAL DL)
)

 

I would have a defun that does all the work this way your command line is something like ^c^C(setq onofflay "layer1")(onoff onofflay) with the lisp onoff autoloaded at start up.

Link to comment
Share on other sites

Another by Lee Mac:

(defun c:lsw (/ lay1 lay2)
 (vl-load-com)
 (and (setq lay1 (tblobjname "LAYER" "name of one layer");change
            lay1 (vlax-ename->vla-object lay1))
      (setq lay2 (tblobjname "LAYER" "name of another layer");change
            lay2 (vlax-ename->vla-object lay2))
      (cond ((eq :vlax-true (vla-get-layeron lay1))
             (vla-put-layeron lay1 :vlax-false)
             (vla-put-layeron lay2 :vlax-true))
            (t (vla-put-layeron lay2 :vlax-false)
               (vla-put-layeron lay1 :vlax-true))))
 (princ))

 

Call it - lsw and hit enter to flip between layers.

Link to comment
Share on other sites

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...