Programmatically locked layers won't fade

Programmatically locked layers won't fade

Paulio
Advocate Advocate
770 Views
2 Replies
Message 1 of 3

Programmatically locked layers won't fade

Paulio
Advocate
Advocate
I have the following sub:
{code}
''' (summary) Locks or unlocks all layers in the drawing (summary)
''' (param name="Lock") Set to True if layers are to be locked or False to unlock (/param)
''' (remarks) If locking, the current layer is left unlocked (/remarks)
Public Sub LockLayers(ByVal Lock As Boolean)
Dim db As Database = HostApplicationServices.WorkingDatabase
Using trans As Transaction = db.TransactionManager.StartTransaction
Dim lt As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForWrite)
For Each objID As ObjectId In lt
Dim ltr As LayerTableRecord = trans.GetObject(objID, OpenMode.ForRead)
Dim curLayer As ObjectId = db.Clayer
If curLayer <> objID Then
ltr.UpgradeOpen()
ltr.IsLocked = Lock
End If
Next
trans.Commit()
End Using
End Sub
{code}

It works fine and locks all the layers (except the current one) but the locked layers don't fade out as they do when it's done through the layer manager.
I can get them to fade if I set the LAYLOCKFADECTL system variable but i can't then get them to "un-fade" when they're unlocked using the same method.
I'd rather not have to set the system variable anyway.

I've tried regen and updatescreen but no joy.

Is there something else I need to update/refresh to get them to grey-out properly?

Thanks.
0 Likes
771 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
You have to set the LAYLOCKFADECTL after you're through modifying the layers...no way around it.
0 Likes
Message 3 of 3

SRSDS
Advisor
Advisor

I've worked out that for unlocking you can toggle the LAYLOCKFADECTL off and on to  give the drawing a kick.

 

Dim int As Integer = Application.GetSystemVariable("LAYLOCKFADECTL")
Application.SetSystemVariable("LAYLOCKFADECTL", 0)
Application.SetSystemVariable("LAYLOCKFADECTL", int)