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

LayerStates Manager 2008

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
151 Views, 0 Replies

LayerStates Manager 2008

Has anybody successfully used the new feature of the layer states manager- ImportLayerStatefrom DB?

Here is some sample code but I get an unhandle exception:
"Object Reference not set to an Instance of an Object"

Using Application.DocumentManager.MdiActiveDocument.LockDocument

Using LayMan As LayerStateManager = Application.DocumentManager.MdiActiveDocument.Database.LayerStateManager
Dim Id As ObjectId = LayMan.LayerStatesDictionaryId(True)


Dim Tid As ObjectId
Try
For x As Integer = 0 To States.Count - 1
Dim NewDB As Database = New Database(True, True)
NewDB.ReadDwgFile(dwgName, IO.FileShare.Read, False, "")
Try
LayMan.ImportLayerStateFromDb(States.Item(x), NewDB)
Catch ex As Autodesk.AutoCAD.Runtime.Exception
MsgBox(ex.Message & vbCrLf & ex.InnerException.ToString & vbCrLf & ex.ErrorStatus)
Finally
NewDB.Dispose()
End Try

LayMan.SaveLayerState(States.Item(x), 1023, Tid)
Next
Catch ex As Autodesk.AutoCAD.Runtime.Exception

MsgBox(ex.Message & vbCrLf & ex.InnerException.ToString & vbCrLf & ex.ErrorStatus)
End Try

End Using
End Using
Application.DocumentManager.MdiActiveDocument.LockDocument.Dispose()
0 REPLIES 0

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