adding LayerTableRecord
Hi,
I have this code to create a new layer:
LayerTable lt = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForWrite);
if (lt.Has(layerName))
return;
LayerTableRecord x = new LayerTableRecord();
x.Name = layerName;
x.LineWeight = LineWeight.ByLineWeightDefault;
x.IsOff = false;
x.IsFrozen = false;
x.IsLocked = false;
x.Color = c;
x.IsPlottable = true;
x.Description = layerDescription;
lt.Add(x);
tr.AddNewlyCreatedDBObject(x, true);
When the line
x.Description = layerDescription;
is executed I have an eNotDatabase exception.
This sounds very strange for me and I don't understand where the problem is.
Thank you very much
0
Comments
-
Hello Andrea,
Some properties require the object be added to the database, try moving :
x.Description = layerDescription;
to after :
lt.Add(x);
tr.AddNewlyCreatedDBObject(x, true);cheers
0 -
Yes, it works
Thank you
0
