Hi all,
I'm doing something wrong but I don't know what ! What I want do to is to set a default layer (in this case layer 0) on several close documents. It does put the good layer but in the ribbon, the layer is blank (see image).
Here is my code :
private void btnTraiter2_Click(object sender, EventArgs e)
{
bool Ok2Continue = true;
for (int i = 0; i < dwgLst.Count; i++)
{
Database db
= new Database
(false,
true); using (db)
{
string fileName = dwgLst.GetKey(i).ToString();
try { db.ReadDwgFile(fileName, FileShare.ReadWrite, false, ""); }
catch (Autodesk.AutoCAD.Runtime.Exception ex) { Ok2Continue = false; }
if (Ok2Continue)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
listLayerID = listDWGLayerID[fileName];
ObjectId id = ObjectId.Null;
if (listLayerID.ContainsKey("0")) id = listLayerID["0"];
db.Clayer = id;
tr.Commit();
}
}
try { db.SaveAs(fileName, true, db.OriginalFileVersion, db.SecurityParameters); }
catch { MessageBox.Show("Error", "Error"); }
}
db.Dispose();
}
}
I have check with debug mode to make sure I apply a valid layer ID and it does.
It should work because everything was working fine but then I made some change and it doesn't work now !
It was even working for all other properties such as textstyle, leaderstyle, dimstyle ...
Thanks for your precious help !