TheSwamp
September 08, 2010, 07:31:34 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Login Register  
Pages: [1] |   Go Down
  Print  
Author Topic: VBA or Diesel expressions for layers on?  (Read 169 times)
0 Members and 1 Guest are viewing this topic.
hardwired
Newt

Posts: 103




Ignore
« 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,
Logged

Cheers,

PaulRenegade @ hardwiredstudios..

XP Pro / AutoCAD 2007 : Pentium Core 2 Q6600 Quad Core : ASUS P5N-E SLI Motherboard
4GB DDR2 RAM : 2 x SLI NVIDIA 8500GT SLi 1024MB DDR2 PCI-Express Graphics Cards..
ChristopherF
Newt

Posts: 52




Ignore
« 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
Logged
Keith™
Villiage Idiot
Seagull

Posts: 12890


Superior Stupidity at its best


WWW

Ignore
« Reply #2 on: November 18, 2009, 05:00:10 pm »

I don't see the LISP entry, so here it is in lisp ...

Code:
(if (< -1 (cdr(assoc 62 (tblsearch "layer" "LSC-WATERMARK"))))
  (vl-cmdf "-layer" "off" "LSC-WATERMARK" "")
  (vl-cmdf "-layer" "on" "LSC-WATERMARK" "")
)
Logged

Don't mind me, I'm just an arrogant and opinionated SA
Bobby C. Jones
Bull Frog

Posts: 384


Cry havoc and let loose the dogs of war.


WWW

Ignore
« 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.
Logged

ChristopherF
Newt

Posts: 52




Ignore
« 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
Logged
Pages: [1] |   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!