public void HighlightSoftPointer() { using (Transaction tr = AcadFuncs.GetActiveDb().TransactionManager.StartTransaction()) { DBDictionary dict = GetDict(tr); if (null == dict) { return; } Xrecord xrec = tr.GetObject(dict.GetAt(XREC_NAME), OpenMode.ForRead) as Xrecord; if (null == xrec) { return; } ObjectId obj_id = (ObjectId)xrec.Data.AsArray()[0].Value; Entity ent = tr.GetObject(obj_id, OpenMode.ForRead) as Entity; if (null == ent) { return; } if (ent is Line) { Line line = ent as Line; line.UpgradeOpen(); line.ColorIndex = 1; } tr.Commit(); } }
private DBDictionary GetDict(Transaction tr) { DBDictionary dict = null; DBDictionary db_dict = tr.GetObject(AcadFuncs.GetActiveDb().NamedObjectsDictionaryId, OpenMode.ForRead) as DBDictionary; if (null == db_dict) { tr.Dispose(); return(null); } if (!db_dict.Contains(DICT_NAME)) { dict = new DBDictionary(); dict.TreatElementsAsHard = true; db_dict.UpgradeOpen(); db_dict.SetAt(DICT_NAME, dict); tr.AddNewlyCreatedDBObject(dict, true); db_dict.DowngradeOpen(); } else { dict = tr.GetObject((ObjectId)db_dict[DICT_NAME], OpenMode.ForRead) as DBDictionary; } return(dict); }
public void SoftPointer() { using (Transaction tr = AcadFuncs.GetActiveDb().TransactionManager.StartTransaction()) { DBDictionary dict = GetDict(tr); if (null == dict) { return; } ObjectId sel_ent_id = GetBlkTblRcd(tr); // PickSingleEnt(); if (ObjectId.Null == sel_ent_id) { return; } AddXRecord(tr, dict, XREC_NAME, sel_ent_id); tr.Commit(); } }
public void AddXdata() { using (Transaction tr = AcadFuncs.GetActiveDb().TransactionManager.StartTransaction()) { RegAppTable reg_app = tr.GetObject(AcadFuncs.GetActiveDb().RegAppTableId, OpenMode.ForRead) as RegAppTable; if (null == reg_app) { tr.Dispose(); return; } if (!reg_app.Has(XDATA_APP)) { RegAppTableRecord reg_app_rcd = new RegAppTableRecord(); reg_app_rcd.Name = XDATA_APP; reg_app.UpgradeOpen(); reg_app.Add(reg_app_rcd); tr.AddNewlyCreatedDBObject(reg_app_rcd, true); } PromptEntityResult prmpt_ent_ret = AcadFuncs.GetEditor().GetEntity("Chọn 1 entity:"); Entity ent = tr.GetObject(prmpt_ent_ret.ObjectId, OpenMode.ForRead) as Entity; if (null == ent) { tr.Dispose(); return; } ent.UpgradeOpen(); ResultBuffer buffer = new ResultBuffer(); buffer.Add(new TypedValue((int)DxfCode.ExtendedDataRegAppName, XDATA_APP)); buffer.Add(new TypedValue((int)DxfCode.ExtendedDataReal, 100.0)); ent.XData = buffer; tr.Commit(); } }