System Variable Toggle Button

System Variable Toggle Button

heather_o
Enthusiast Enthusiast
1,205 Views
6 Replies
Message 1 of 7

System Variable Toggle Button

heather_o
Enthusiast
Enthusiast
I am not good with Lisp Routines but I would like to create a lisp or a button to toggle on and off the default dimension layer.   There are times I need a dimension on a different layer than other dimensions.  (i.e. interior dimensions)
Is there a way to toggle on/off the default dimension layer?
I'm currently on 2019
0 Likes
Accepted solutions (1)
1,206 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant

Not really sure if I fully understand, so try.

If is frozen, then it's thawed.

 

(defun c:DimLayerToggle (/ l e)

  (or (/= "." (setq l (getvar 'dimlayer)))
      (setq l "DimLayer"))  ; put some name here

  (if (or (setq e (tblobjname "layer" l))
	  (prompt "\nError: No default layer found."))
    (if (or (= 1 (getpropertyvalue e "IsFrozen"))
	    (= 1 (getpropertyvalue e "IsOff"))
	    )
      (progn
	(setpropertyvalue e "IsFrozen" 0)
	(setpropertyvalue e "IsOff" 0)
	(princ (strcat "\nDIMLayer '" l "' turned ON")))
      (progn
	(setpropertyvalue e "IsOff" 1)
	(princ (strcat "\nDIMLayer '" l "' turned OFF")))))
  (princ)
  )

 

 
0 Likes
Message 3 of 7

heather_o
Enthusiast
Enthusiast

Thank  you!  I will give this a try!

 

This is what I tried while waiting for a response.  I created 2 lisp routines.  1 to turn the dimlayer to A-Anno-Dims and the other to turn it to A-Anno-Dims-Intr.

It's very basic as I know very little.

 

(defun c:AD ()
(setvar "dimlayer" "a-anno-dims")
) ;end defun

 

(defun c:ADI ()
(setvar "dimlayer" "a-anno-dims-intr")
) ;end defun

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant

I might misunderstand the whole thing.

You just want to switch 'dimlayer sysvar between two layers?

0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@heather_o wrote:

....  I created 2 lisp routines.  1 to turn the dimlayer to A-Anno-Dims and the other to turn it to A-Anno-Dims-Intr. ....


If it's just a matter of turning off and on the specifying of a default Layer for Dimensions, whatever that is, i.e. switching between a specific Layer and the current one, it could be as simple as this:

(defun C:DLT (); = Dimension Layer Toggle
  (if (not dllist) (setq dl (getvar 'dimlayer)))
  (setq dllist (list (list dl ".") (list "." dl)))
  (setvar 'dimlayer (cadr (assoc (getvar 'dimlayer) dllist)))
); defun

 

If the designated Layer will always be one of those two you describe, and both will always exist in the drawing, you can toggle between them with just one command:

 

(vl-load-com)
(defun C:DLTA (); = Dimension Layer Toggle between two specific Annotation Layers
  (setq dllist '("a-anno-dims" "a-anno-dims-intr"))
  (setvar 'dimlayer (car (vl-remove (getvar 'dimlayer) dllist)))
); defun

Kent Cooper, AIA
Message 6 of 7

Sea-Haven
Mentor
Mentor

It could also be a pick dim style from a radio button dcl written into lisp code similar to dimstyle but simplified. Using 2 defuns is simple though and works, for me D1 D2 D3 etc.

0 Likes
Message 7 of 7

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

.... Using 2 defuns is simple though and works....


Yes, and it does have certain advantages over straight toggles like my suggestions.

 

If you have a "standard" Layer for Dimensions, but you sometimes want to ignore that and put a Dimension on whatever the current Layer is, my DLT command will set it to ignore that standard if it is current at the time, and when used again will restore that standard.  But if you close the drawing when it's set to ignore ["."], you will "lose" the standard Layer name.  So when you re-open the drawing, you will need to explicitly re-enter the standard [or have another command to do that], or DLT will just "toggle between" use-the-current-Layer and the same.  I suppose it could be expanded to recognize the first time it's used, and if the current setting at the time is ".", to re-establish the standard Layer name into its list.

 

If you have only the two standard Layer names, my DLTA command will switch between them, but you can't easily tell which is the current setting, so you may not know when you need to use it.  When you do use it, at least it reports the Layer it's been set to, so you can tell whether to use it again to go back, if it put you in the one you didn't want.  And if you happen to set the Dimensions Layer to something other than those two, including the use-the-current-Layer option, DLTA will always change the setting to the first one in the list, which won't always be the one you want, so you could need to use it again.

 

Having two explicit Layer-assigning commands, rather than a toggle, means you can always go directly to the one you want, without needing to know whether it may already be the current setting.

Kent Cooper, AIA
0 Likes