Valued Contributor
52 Posts
0 Kudos
Registered: ‎03-27-2006
Post 1 of 2

layers order

70 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
52 Posts
0 Kudos
Registered: ‎03-27-2006
Post 2 of 2

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 interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!