VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why does the locked layers not fading with vba?

2 REPLIES 2
Reply
Message 1 of 3
lanieuwe
650 Views, 2 Replies

Why does the locked layers not fading with vba?

I have this application:

It's a userform with a combobox filled up with all layers. There also are 2 commandbuttons and a label.

When I apply the command button all the layers except the selected layer in the combobox lock. That's good.

This is the problem:

Normaly when I lock a layer it is fading (laylockfadectl 80). But when I lock layers with this vba code it doesn't fading locked layers. Can someone help?

 

gr. laszlo

Option Explicit

Private Sub cmbx1_Change()
Label1.Caption = cmbx1.Value
End Sub

Private Sub cmdAPPLY_Click()
On Error Resume Next 'handle exceptions inline
Dim objlayers As AcadLayers Dim objlayer As AcadLayer
Set objlayers = ThisDrawing.Layers 'make the layer selected in the combobox current ThisDrawing.ActiveLayer = objlayers.Item(cmbx1.Text) For Each objlayer In objlayers objlayer.Lock = True 'lock all the layers Next objlayer Set objlayer = objlayers.Item(cmbx1.Text) If objlayer Is Nothing Then MsgBox "layer does not exist" Exit Sub 'exit if layer not found End If objlayer.Lock = False 'unlock the desired layer End Sub Private Sub cmdEXIT_Click() Dim objlayer As AcadLayer
For Each objlayer In ThisDrawing.Layers objlayer.Lock = False Next Unload frm1 End Sub
Private Sub Label1_Click() On Error Resume Next 'handle exceptions inline Dim objlayers As AcadLayers Dim objlayer As AcadLayer
Set objlayers = ThisDrawing.Layers Me.Caption = objlayers.Item(cmbx1.Text) End Sub
Private Sub UserForm_Initialize() Dim layerColl As AcadLayers Dim objlayer As AcadLayer
'fill combobox Set layerColl = ThisDrawing.Layers For Each objlayer In layerColl cmbx1.AddItem objlayer.Name Next End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Dim objlayer As AcadLayer
For Each objlayer In ThisDrawing.Layers objlayer.Lock = False Next End Sub

 

2 REPLIES 2
Message 2 of 3
lanieuwe
in reply to: lanieuwe

Nobody?

Normaly you can fading layers to lock them and set laylockfadectl for example to 80.

 

I have this setting normaly on 80.

When I lock a layer in the layermanager, this layer will be fade. 

 

When I lock a layer with vba code it doesn't fade?

 

Why is that ??.

 

please see my code.

 

gr laszlo

Message 3 of 3
gerrardhickson
in reply to: lanieuwe

Old post, I realise, but I had this same problem in ACADM 2022.
I found the solution (for me atleast) was to set the LAYERLOCKFADECTL variable to 0, then to the original value

 

oDoc.SetVariable "LAYLOCKFADECTL", 0
oDoc.SetVariable "LAYLOCKFADECTL", 50
oDoc.Regen acAllViewports

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost