Valued Contributor
Posts: 52
Registered: ‎03-27-2006
Message 1 of 2 (62 Views)

layers order

62 Views, 1 Replies
05-10-2006 06:34 AM
Hi there,
Please can somebody help. I really didn't find solution to this problem.

problem specification:
I am using AutoCAD 2006 and C# as a programing language. in my C# code there is a new layer will be created and new blocks also. this is not the problem i found the solution for that in another discussion but the problem is when i am creating a new layer i couldn't put that layer between other layer which are already exist in the acad document. i have to append it to the existed layers that means it will be the lower layer.
i want the layers be in a specific order. specially layer 0 i want that layer to be the lowest.
Can i do that using C#??
thanks in advanced.
and sorry for bad english :smileyhappy:
Valued Contributor
Posts: 52
Registered: ‎03-27-2006
Message 2 of 2 (62 Views)

Re: layers order

05-10-2006 07:12 AM in reply to: Nawara17
Just to specify i am using the following code to create the layer:

static ObjectId CreateLayer()
ObjectId layerId; //the return value for this function
Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForWrite);
if (lt.Has("test"))
layerId = lt["test"];
//if not, create the layer here.
LayerTableRecord ltr = new LayerTableRecord();
ltr.Name = "test"; // Set the layer name
ltr.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 2);
layerId = lt.Add(ltr);
trans.AddNewlyCreatedDBObject(ltr, true);


return layerId;

and it works. i copied it form other discussions, but when the layer created in the autoCAD it will be in the following order

what i want is to be in the reverse order
0 Message was edited by: Nawara17

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community