Author Topic: Activate/Unfreeze Layers  (Read 988 times)

Offline rom1

  • Visual Basic
  • Newbie
  • *
  • Posts: 21
  • Karma: +3/-0
  • Gender: Male
    • prefered language: VB
    • Prog expertise: Good
    • View Profile
Activate/Unfreeze Layers
« on: November 18, 2010, 10:49:15 AM »
Hi,

A little function in vb in order to make a layer active and not frozen:

Code: [Select]

    Sub LayerActiveUnfreeze(ByVal LayerName As String)

        Dim DocBd As Database = ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database

        Using myTrans As Transaction = DocBd.TransactionManager.StartTransaction
            Try
                Dim myLayerTable As LayerTable = DocBd.LayerTableId.GetObject(OpenMode.ForRead)
                For Each myLTRid As ObjectId In myLayerTable
                    Dim myLayer As LayerTableRecord = myLTRid.GetObject(OpenMode.ForRead)
                    If myLayer.Name Like LayerName Then
                        If myLayer.IsFrozen Then
                            myLayer.UpgradeOpen()
                            myLayer.IsFrozen = False
                        End If
                        If myLayer.IsLocked Then
                            myLayer.UpgradeOpen()
                            myLayer.IsLocked = False
                        End If
                    End If
                Next
            Catch ex As Exception
                myTrans.Abort()
            Finally
                myTrans.Commit()
            End Try
        End Using
    End Sub

target audience:{intermediate}
« Last Edit: November 21, 2010, 05:41:47 PM by Patriiick »