Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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

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 :)

  • Yes, it works

    Thank you

Sign In or Register to comment.
Origami
Origami is the Japanese word for paper folding. ORI means to fold and KAMI means paper and involves the creation of paper forms usually entirely by folding.

Powered by VanillaForums, Designed by Steam