.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

All Layer Freeze

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
322 Views, 3 Replies

All Layer Freeze

Hi, all.
All layer on or off is working well.
But all layer freeze or thaw is not working, no change made.
To happen this, how should I repair my code?
Some help?

Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager
Dim tr As Transaction = tm.StartTransaction()
Try
Dim lt As LayerTable = CType(tm.GetObject(db.LayerTableId, OpenMode.ForRead), LayerTable)
lt.UpgradeOpen()
For Each objId As ObjectId In lt
Dim ireum As String = CType(tm.GetObject(objId, OpenMode.ForRead), LayerTableRecord).Name
Dim lyr As LayerTableRecord = CType(tm.GetObject(objId, OpenMode.ForWrite), LayerTableRecord)
lyr.IsFrozen = True
If ireum = "0" Then
lyr.IsFrozen = False
End If
ALF.Update()
Next
tr.Commit()
Application.DocumentManager.MdiActiveDocument.Editor.Regen()
Catch ex As Exception
tr.Abort()
Finally
tr.Dispose()
End Try
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Try this...

Imports AcDb = Autodesk.AutoCAD.DatabaseServices
Imports AcRx = Autodesk.AutoCAD.Runtime

_
Public Sub AllLayersFreeze()
Using db As AcDb.Database =
AcDb.HostApplicationServices.WorkingDatabase()
Using tr As AcDb.Transaction =
db.TransactionManager.StartTransaction
Try
Dim tbl As AcDb.LayerTable = _
CType(tr.GetObject(db.LayerTableId,
AcDb.OpenMode.ForRead, False), AcDb.LayerTable)
For Each id As AcDb.ObjectId In tbl
Dim layer As AcDb.LayerTableRecord = tr.GetObject(id,
AcDb.OpenMode.ForRead, False)
If db.Clayer <> id AndAlso Not layer.IsFrozen Then
layer.UpgradeOpen()
layer.IsFrozen = True
End If
Next
tr.Commit()
Catch ex As Exception
tr.Abort()
End Try
End Using
End Using
End Sub

_
Public Sub AllLayersThawn()
Using db As AcDb.Database =
AcDb.HostApplicationServices.WorkingDatabase()
Using tr As AcDb.Transaction =
db.TransactionManager.StartTransaction
Try
Dim tbl As AcDb.LayerTable = _
CType(tr.GetObject(db.LayerTableId,
AcDb.OpenMode.ForRead, False), AcDb.LayerTable)
For Each id As AcDb.ObjectId In tbl
Dim layer As AcDb.LayerTableRecord = tr.GetObject(id,
AcDb.OpenMode.ForRead, False)
If layer.IsFrozen Then
layer.UpgradeOpen()
layer.IsFrozen = False
End If
Next
tr.Commit()
Catch ex As Exception
tr.Abort()
End Try
End Using
End Using
End Sub

tp



I'm protected by SpamBrave
http://www.spambrave.com/
Message 3 of 4
Anonymous
in reply to: Anonymous

Thank you so much,tp.
Happy day!
Message 4 of 4
Anonymous
in reply to: Anonymous

do you have express tools? does "layfrz" and "laythw" work? just
checking....if so - real easy to make the toolbuttons for.


wrote in message news:5460365@discussion.autodesk.com...
Hi, all.
All layer on or off is working well.
But all layer freeze or thaw is not working, no change made.
To happen this, how should I repair my code?
Some help?


Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim db As Database =
Application.DocumentManager.MdiActiveDocument.Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager =
db.TransactionManager
Dim tr As Transaction = tm.StartTransaction()
Try
Dim lt As LayerTable = CType(tm.GetObject(db.LayerTableId,
OpenMode.ForRead), LayerTable)
lt.UpgradeOpen()
For Each objId As ObjectId In lt
Dim ireum As String = CType(tm.GetObject(objId,
OpenMode.ForRead), LayerTableRecord).Name
Dim lyr As LayerTableRecord = CType(tm.GetObject(objId,
OpenMode.ForWrite), LayerTableRecord)
lyr.IsFrozen = True
If ireum = "0" Then
lyr.IsFrozen = False
End If
ALF.Update()
Next
tr.Commit()
Application.DocumentManager.MdiActiveDocument.Editor.Regen()
Catch ex As Exception
tr.Abort()
Finally
tr.Dispose()
End Try

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost