Message 1 of 3
Programmatically locked layers won't fade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
{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.