I hope that this can help you
Shared Function ActivateLayer(ByVal LayerID As AcDb.ObjectId) As
AcDb.ObjectId
Using db As AcDb.Database =
AcDb.HostApplicationServices.WorkingDatabase()
Using tr As AcDb.Transaction =
db.TransactionManager.StartTransaction
Try
Dim tbl As AcDb.LayerTable = _
DirectCast(tr.GetObject(db.LayerTableId,
AcDb.OpenMode.ForRead, False), AcDb.LayerTable)
If tbl.Has(LayerID) Then
db.Clayer = LayerID
tr.Commit()
Else
tp.Utils.GetEditor.WriteMessage(vbLf & "Layer not
exists")
End If
Catch ex As Exception
tr.Abort()
End Try
End Using
End Using
Return LayerID
End Function
Shared Function ActivateLayer(ByVal LayerName As String) As
AcDb.ObjectId
Dim id As AcDb.ObjectId = LayerNameToId(LayerName)
If Not id = Nothing Then
Return tp.Layers.ActivateLayer(id)
End If
Return Nothing
End Function
Shared Function LayerNameToId(ByVal LayerName As String) As
AcDb.ObjectId
Dim tbl As AcDb.LayerTable = GetLayerTableForRead
If tbl.Has(LayerName) Then
Return tbl.Item(LayerName)
End If
Return Nothing
End Function
Shared Function GetLayerTableForRead() As AcDb.LayerTable
Using db As AcDb.Database =
AcDb.HostApplicationServices.WorkingDatabase()
Using tr As AcDb.Transaction =
db.TransactionManager.StartTransaction
Try
Return DirectCast(tr.GetObject(db.LayerTableId,
AcDb.OpenMode.ForRead, False), AcDb.LayerTable)
Catch ex As Exception
End Try
End Using
End Using
Return Nothing
End Function
tp
escreveu na mensagem news:5714229@discussion.autodesk.com...
I'm using VB.net 2005 and AutoCAD 2007. I have seen a lot of suggestions
but none of them work. Does anyone know how to change the active layer to a
layer that already exist? Please don't just give me a line of code without
saying what namespaces are needed.
Thanks,