TheSwamp
Code Red => VB(A) => Topic started by: hardwired on November 12, 2009, 03:01:53 AM
-
Hi,
Could someone help me out with a diesel expression (and VBA) i can use for a button macro? I want to toggle a layer on or off, nothing more than that but i don't know much diesel..
The layer is LSC-WATERMARK, so its only gonna be like:
If LSC-WATERMARK is ON then, turn OFF LSC-WATERMARK and vice versa (obvious i know)..
I've posted this in the AutoLISP forum to request the AutoLISP and Diesel versions..
Thanks in advance,
-
Hi,
Could someone help me out with a diesel expression (and VBA) i can use for a button macro? I want to toggle a layer on or off, nothing more than that but i don't know much diesel..
The layer is LSC-WATERMARK, so its only gonna be like:
If LSC-WATERMARK is ON then, turn OFF LSC-WATERMARK and vice versa (obvious i know)..
I've posted this in the AutoLISP forum to request the AutoLISP and Diesel versions..
Thanks in advance,
Here's how to do it VBA:
Sub TurnOffLayer()
If ThisDrawing.Layers.Item("LSC-WATERMARK").LayerOn = True Then
ThisDrawing.Layers.Item("LSC-WATERMARK").LayerOn = False
Else
ThisDrawing.Layers.Item("LSC-WATERMARK").LayerOn = True
End If
End Sub
-
I don't see the LISP entry, so here it is in lisp ...
(if (< -1 (cdr(assoc 62 (tblsearch "layer" "LSC-WATERMARK"))))
(vl-cmdf "-layer" "off" "LSC-WATERMARK" "")
(vl-cmdf "-layer" "on" "LSC-WATERMARK" "")
)
-
Here's how to do it VBA:
Sub TurnOffLayer()
If ThisDrawing.Layers.Item("LSC-WATERMARK").LayerOn = True Then
ThisDrawing.Layers.Item("LSC-WATERMARK").LayerOn = False
Else
ThisDrawing.Layers.Item("LSC-WATERMARK").LayerOn = True
End If
End Sub
Another concise way to toggle a bool value is to simply set the value to what it's Not.
-
Another concise way to toggle a bool value is to simply set the value to what it's Not.
Thanks, learned something new today. It is way more consice.
ThisDrawing.Layers.Item("LSC-WATERMARK").LayerOn = Not ThisDrawing.Layers.Item("LSC-WATERMARK").LayerOn