本次由重庆区公民若海同志提供,嘻嘻…

lisp语句:
(vlax-ldata-put (car (entsel)) “basepoint” “测试结果”)

  1. [DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl)]
  2. static extern IntPtr acdbEntGet(AdsName objName);
  3. [DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl)]
  4. static extern IntPtr acdbEntGetX(AdsName objName, IntPtr app);
  5. [DllImport("acdb19.dll",
  6. CallingConvention = CallingConvention.Cdecl,
  7. EntryPoint = "?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AEAY01_JVAcDbObjectId@@@Z")]
  8. static extern ErrorStatus acdbGetAdsName64(out AdsName objName, ObjectId id);
  9. [CommandMethod("tt")]
  10. public static void CB_GetDict()
  11. {
  12. Document m_Document = Application.DocumentManager.MdiActiveDocument;
  13. using (Transaction m_Transaction = m_Document.Database.TransactionManager.StartTransaction())
  14. {
  15. var id = Application.DocumentManager.MdiActiveDocument.Editor.GetEntity("ce").ObjectId;
  16. DBObject obj = m_Transaction.GetObject(id, OpenMode.ForRead);
  17. //获取对象的扩展字典
  18. ObjectId dictId = obj.ExtensionDictionary;
  19. DBDictionary m_DBDictionary = (DBDictionary)m_Transaction.GetObject(dictId, OpenMode.ForRead);
  20. if (m_DBDictionary != null)
  21. {
  22. ObjectId m_DictObjectId = m_DBDictionary.GetAt("basepoint");
  23. DBObject m_ImpDBObjectAsDBObject = (DBObject)m_Transaction.GetObject
  24. (m_DictObjectId,
  25. OpenMode.ForRead);
  26. ResultBuffer m_Resultbuffer = new ResultBuffer();
  27. AdsName m_EName = new AdsName();
  28. acdbGetAdsName64(out m_EName, m_ImpDBObjectAsDBObject.ObjectId);
  29. IntPtr m_IntPrResult = acdbEntGetX(m_EName, m_Resultbuffer.UnmanagedObject);
  30. if (m_IntPrResult != IntPtr.Zero)
  31. {
  32. m_Resultbuffer = ResultBuffer.Create(m_IntPrResult, true);
  33. Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(m_Resultbuffer.ToString());
  34. }
  35. }
  36. m_Transaction.Commit();
  37. }
  38. }

p.png