Message 1 of 5

Not applicable
07-21-2020
11:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
i am make function in net autocad using C#
i want change layer.color by int and change layer.lineweight by double
how to do this
public static ObjectId addlayer(string namalayer,double lineweight,int color)
{
var doc = app.DocumentManager.MdiActiveDocument;
var db = doc.Database;
ObjectId idx = db.LayerTableId;
using (Transaction acTrans = db.TransactionManager.StartTransaction())
{
LayerTable acLyrTbl;
acLyrTbl = acTrans.GetObject(db.LayerTableId,OpenMode.ForRead) as LayerTable;
if (acLyrTbl.Has(namalayer) == false)
{
LayerTableRecord acLyrTblRec = new LayerTableRecord();
acLyrTblRec.Color = Color.FromColorIndex(ColorMethod.ByColor, color);
acLyrTblRec.LineWeight = lineweight;
acLyrTblRec.Name = namalayer;
acLyrTbl.UpgradeOpen();
idx= acLyrTbl.Add(acLyrTblRec);acTrans.AddNewlyCreatedDBObject(acLyrTblRec, true);
db.Clayer = idx;
}
else
{
db.Clayer = acLyrTbl[namalayer];
}
acTrans.Commit();
return idx;
}
}
Solved! Go to Solution.