如果图元比较少时可以试下
[CommandMethod("CTest")] public void test() {
var db = HostApplicationServices.WorkingDatabase; var doc = Application.DocumentManager.GetDocument(db); var ed = doc.Editor; using (Transaction tr = db.TransactionManager.StartTransaction()) {
var lt = db.LayerTableId.GetObject<LayerTable>(); var ltr = lt["1"].GetObject<LayerTableRecord>(OpenMode.ForWrite); ltr.IsLocked = true; short llf = Convert.ToInt16( Application.GetSystemVariable("LAYLOCKFADECTL")); Application.SetSystemVariable("LAYLOCKFADECTL", (short)-90); Application.SetSystemVariable("LAYLOCKFADECTL", llf); tr.Commit(); } } |