hi - i'm stuck at trying the above:
a new layer is created fine, name checked and assigned, colour assigned, plot property, all fine (and as per the autocad .net developer illustration for creating layers).
however, the description string is not attached to the new layer; i tried
newlayer.description = "string",
newlayer.description = stringvariable, and lastly
newlayer.description.insert(0, "string").
no success, the description property of the newly created layer stays empty.
suggestions welcome, thanks
felix
Solved! Go to Solution.
Solved by jeff. Go to Solution.
Hi,
what AutoCAD version do you use? And just to make sure ... you don't get an exception?
- alfred -
hi alfred
no exceptions, no; i'm using autocad 2011 with vs2010 and the .net framework 4.
also, i've used the debugger to check .isnewobject (which shows true for the new layer) and the .description property (which is simply blank).
felix
Hi Felix,
I have noticed this with certain properties for oyher objects but usually the first thing I will try is to set the property after it has been added to the database.
Not sure why it is like this.
I guess you are using VB but here is a example
<CommandMethod("CreateNewLayer")> _ Public Sub CreateNewLayer() Dim layerName As String = "TestLayer" Dim layerDescription As String = "This is TestLayers Description" Dim doc As Document = Application.DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim ed As Editor = doc.Editor Using trx As Transaction = db.TransactionManager.StartTransaction Dim lt As LayerTable = trx.GetObject(db.LayerTableId, OpenMode.ForRead) If Not lt.Has(layerName) Then lt.UpgradeOpen() Dim ltr As LayerTableRecord = New LayerTableRecord() ltr.Name = layerName ltr.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 1) lt.Add(ltr) trx.AddNewlyCreatedDBObject(ltr, True) ltr.Description = layerDescription End If trx.Commit() End Using End Sub