AutoCAD 2004/2005/2006

AutoCAD 2004/2005/2006

Reply
Member
4 Posts
0 Kudos
Registered: ‎09-10-2009
Post 1 of 2

Turning on or Off Layers using VBA

233 Views, 1 Replies
09-10-2009 05:09 AM
Hi all,

I am currently working on a program which has links to various drawings. The code i have works fine for opening the drawing however when there is a checkbox selected in excel i would like it to turn off a specific layer in the AutoCAD .drg.

The code i am using is attached however it doesn't actually do anything, can anyone help?

Dim acad As New AcadApplication
Dim objLayer As IAcadLayer
Dim unitvalid As String
Dim strLayerName As String
Dim HighAmbientOtion As String

'get drawing name and open in Autocad 2006
T1 = drawingFolder & T1

acad.Visible = True
acad.Application.WindowState = 3
acad.Application.Documents.Open (T1)
Set dwg = acad.ActiveDocument

If Sheets("Main").CheckBox_HighAmbient.Value = True Then
Set objLayer = dwg.Layers(HighAmbientOption)
objLayer.LayerOn = True
objLayer.Freeze = False
ElseIf Sheets("Main").CheckBox_HighAmbient.Value = False Then
Set objLayer = dwg.Layers(HighAmbientOption)
objLayer.LayerOn = False
objLayer.Freeze = True
End If

i have also tried the code without the freeze commands but no joy

Cheers
*Dean Saadallah
Post 2 of 2

Re: Turning on or Off Layers using VBA

09-10-2009 05:14 AM in reply to: peachey123
There is a VBA discussion area, post there.

--
Dean Saadallah
http://LTisACAD.blogspot.com
--
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!