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
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
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