AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Recently the guys here at work wanted me to write a routine that would toggle the display to work in a WYSIWYG (What You See Is What You Get) mode. I did do it with VBA because I didn't think there was a way to do it using Lisp. Am I correct? Could Visual Lisp have done it?

Here is my VBA code:

'CODING STARTS HERE
Sub wysiwyg()
'Toggle Mspace Pspace
If Not (ThisDrawing.ActiveSpace = acPaperSpace) Then
ThisDrawing.ActiveSpace = acPaperSpace
ThisDrawing.SetVariable "dimscale", 1
ThisDrawing.SetVariable "ltscale", ThisDrawing.GetVariable("dimscale") * 0.5
End If
' Toggle Layout Crosshair Color
If Not (ThisDrawing.Application.Preferences.Display.LayoutCrosshairColor = vbBlack) Then
ThisDrawing.Application.Preferences.Display.LayoutCrosshairColor = vbBlack
Else
ThisDrawing.Application.Preferences.Display.LayoutCrosshairColor = vbWhite
End If
' Toggle Layout Background Color
If Not (ThisDrawing.Application.Preferences.Display.GraphicsWinLayoutBackgrndColor = vbWhite) Then
ThisDrawing.Application.Preferences.Display.GraphicsWinLayoutBackgrndColor = vbWhite
Else
ThisDrawing.Application.Preferences.Display.GraphicsWinLayoutBackgrndColor = vbBlack
End If
' Toggle Show Plot Styles
If Not (ThisDrawing.ActiveLayout.ShowPlotStyles = True) Then
ThisDrawing.ActiveLayout.ShowPlotStyles = True
Else
ThisDrawing.ActiveLayout.ShowPlotStyles = False
End If
' Toggle Lweight Display
If ThisDrawing.GetVariable("LWDISPLAY") = "0" Then
ThisDrawing.SetVariable "lwdisplay", 1
Else
ThisDrawing.SetVariable "lwdisplay", 0
End If
'Lock viewports
Dim Ent As AcadEntity, pVP As AcadPViewport
For Each Ent In ThisDrawing.PaperSpace
Debug.Print Ent.ObjectName
If Ent.ObjectName = "AcDbViewport" Then
Set pVP = Ent
Debug.Print pVP.DisplayLocked
If Not pVP.DisplayLocked Then pVP.DisplayLocked = True
End If
Next Ent
' Regen The Drawing
ThisDrawing.Regen acAllViewports
End Sub
'CODING ENDS HERE

Thanks,

James

The AutoLisp/Visual Lisp/VBA Resource Website

Copyright © 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website