HTH, watch out for word-wrapping.
Joe ...
<CommandMethod("TLOFF")>
_
Public Shared Sub
TurnLayerOff()
'get the editor
object
'Dim ed As Editor =
ThisDrawing.Editor
Dim ed As
Editor = Application.DocumentManager.MdiActiveDocument.Editor
'enter
name of layer
Dim LayerNameOptions
As PromptStringOptions = New PromptStringOptions("Enter layer
name")
'spaces allowed with layer
names
LayerNameOptions.AllowSpaces
= True
'get the
input
Dim LayerNameResult As
PromptResult = ed.GetString(LayerNameOptions)
'if
ok
If (LayerNameResult.Status =
PromptStatus.OK)
Then
'get
the working
database
Dim dwg As Database =
ed.Document.Database
'start a
transaction
Dim ta As Transaction = dwg.TransactionManager.StartTransaction
size=2>
Try
'open layer table for
reading
Dim LayerTable As LayerTable = ta.GetObject(dwg.LayerTableId,
OpenMode.ForRead)
'see if the layer
exists
If LayerTable.Has(LayerNameResult.StringResult) = True
Then
Dim LayerTableRecord As LayerTableRecord =
ta.GetObject(LayerTable.Item(LayerNameResult.StringResult),
OpenMode.ForWrite)
If Not LayerTableRecord = Nothing
Then
'turn off the layer
specified
LayerTableRecord.IsOff =
True
'commit the change to the
database
ta.Commit()
End If
size=2>
Else
MsgBox("The layer " + LayerNameResult.StringResult + " could not be
found")
size=2>
End If
size=2> Catch
ex As
Exception
ed.WriteMessage("A problem occured because " + ex.Message)
size=2>
Finally
'always dispose of
transactions
ta.Dispose()
size=2> End
Try
End If
End Sub
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I've
been playing with the layers objects I've found examples of and so far, I can
create new layers, iterate through them, even capture the ones I want to
modify. But that's where it stops. I can't modify any of the layers I can grab
a hold of. There is only an Add function in the LayerTable object. There is no
update function. So how am I supposed to turn on and off different layers from
.NET when there's no way to actually update the Layer Record that I
have?