Author Topic: VBA or Diesel expressions for layers on?  (Read 3053 times)

0 Members and 1 Guest are viewing this topic.

hardwired

  • Guest
VBA or Diesel expressions for layers on?
« 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,

ChristopherF

  • Newt
  • Posts: 55
Re: VBA or Diesel expressions for layers on?
« Reply #1 on: November 18, 2009, 03:36:06 PM »
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

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: VBA or Diesel expressions for layers on?
« Reply #2 on: November 18, 2009, 05:00:10 PM »
I don't see the LISP entry, so here it is in lisp ...

Code: [Select]
(if (< -1 (cdr(assoc 62 (tblsearch "layer" "LSC-WATERMARK"))))
  (vl-cmdf "-layer" "off" "LSC-WATERMARK" "")
  (vl-cmdf "-layer" "on" "LSC-WATERMARK" "")
)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Bobby C. Jones

  • Swamp Rat
  • Posts: 516
  • Cry havoc and let loose the dogs of war.
Re: VBA or Diesel expressions for layers on?
« Reply #3 on: November 20, 2009, 04:45:31 PM »
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.
Bobby C. Jones

ChristopherF

  • Newt
  • Posts: 55
Re: VBA or Diesel expressions for layers on?
« Reply #4 on: November 20, 2009, 07:34:17 PM »
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