Creating object on specific layer

Hi All
I’m new to Rhino development, so excuse me for any obvious questions…
I’m working with RhinoCommon c#.
I’m trying to create lines on a specific layer (not Default layer) from code. what should be done to assign a layer to object?


   public static Rhino.Commands.Result AddLine(Rhino.RhinoDoc doc, Rhino.Geometry.Point3d start, Rhino.Geometry.Point3d end )

        Rhino.Geometry.Vector3d v = end - start;
        if (v.IsTiny(Rhino.RhinoMath.ZeroTolerance))
            return Rhino.Commands.Result.Nothing;

        if (doc.Objects.AddLine(start, end) != Guid.Empty)
            return Rhino.Commands.Result.Success;
        return Rhino.Commands.Result.Failure;

You need to create ObjectAttributes, and use them when adding a line

On the attributes, you can specify the layer index, which can be obtained from the layers table.

wonderful. thanks