Showing posts with label VBScript. Show all posts
Showing posts with label VBScript. Show all posts

Wednesday, September 19, 2007

Toggle AutoCAD Application Visibility

We can do a lot AutoCAD related programming outside AutoCAD using Windows Script Host. Some of the areas where windows scripting is useful are network management, windows registry manipulation, file or folder acces etc. Here is a sample VBScript code to toggle AutoCAD application visibility state.


On Error Resume Next
Set ObjACAD = GetObject(, "AutoCAD.Application")
If Err.Number <> 0 Then Err.Clear
MsgBox "AutoCAD is not currently running...!!", vbExclamation
Else
If ObjACAD.Visible = True Then
ObjACAD.Visible = False
Else
ObjACAD.Visible = True
End If
End If
Set ObjACAD = Nothing

Just copy the code and paste it inside notepad and save it with a vbs extension. Run the the file while AutoCAD is open. It will toggle the application display everytime you run it. Now you can leave your PC with peace of mind that nobody would interfere with your opened drawings.