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

layers order

66 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 (66 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!