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

Layer creation error

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

Layer creation error

Does anyone have a question why this would be erroring at this point;
"im lt As LayerTable = tm.GetObject(db.LayerTableId, OpenMode.ForWrite, True)"

Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tm As DBTransMan = db.TransactionManager
'start a transaction
Dim myT As Transaction = tm.StartTransaction()
Dim ltr As LayerTableRecord = New LayerTableRecord
ltr.Name = namLay
Dim myColor As New Color()
myColor.ColorIndex() = colLay
ltr.Color() = myColor
If Linetype <> "Continuous" Then ltr.LinetypeObjectId = CheckForLineType(Linetype)
MsgBox("5")
Dim lt As LayerTable = tm.GetObject(db.LayerTableId, OpenMode.ForWrite, True)
lt.Add(ltr)
tm.AddNewlyCreatedDBObject(ltr, True)
ltr.Description = Descrip
myT.Commit()
tm.Dispose()
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Autocad 2005 only
Message 3 of 4
NathTay
in reply to: Anonymous

You are using the transaction manager to get the table instead of the transaction.

Try changing
Dim lt As LayerTable = tm.GetObject(db.LayerTableId, OpenMode.ForWrite, True)
to
Dim lt As LayerTable = myT.GetObject(db.LayerTableId, OpenMode.ForWrite, True)

Regards - Nathan
Message 4 of 4
Anonymous
in reply to: Anonymous

It tried your suggestions and still same error...I evn tried autodesk layer create example for 2005 and still get this error

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