Community
' Define command 'addlayer'
< CommandMethod("addlayer") > _
Public Function AddLayer()
Dim curdb As Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager
Dim myT As Transaction
curdb = Application.DocumentManager.MdiActiveDocument.Database
tm = curdb.TransactionManager
myT = tm.StartTransaction()
Dim lt As LayerTable = CType(tm.GetObject(curdb.LayerTableId, OpenMode.ForWrite), LayerTable)
Dim x As New LayerTableRecord
x.Name = "Test Layer"
x.IsOff = True
x.IsFrozen = True
x.IsLocked = True
'Color RED
x.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 0, 0)
x.LineWeight = LineWeight.LineWeight120
x.IsPlottable = False
x.Description = "Layer insert sucessfully"
lt.Add(x)
myT.AddNewlyCreatedDBObject(x, True)
myT.Commit()
End Function