ConnectToAcad.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* ==============================================================================
  2. * 功能描述:ConnectToAcad
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/12/16 11:54:13
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using Autodesk.AutoCAD.Interop.Common;
  12. using Autodesk.AutoCAD.Runtime;
  13. using SmartSoft.ACAD;
  14. namespace TestCad
  15. {
  16. /// <summary>
  17. /// ConnectToAcad
  18. /// </summary>
  19. class ConnectToAcad
  20. {
  21. public static void Connect(string path)
  22. {
  23. try
  24. {
  25. AutoCADConnector acd = new AutoCADConnector();//生成操作类对象
  26. AxDbDocument doc_as = acd.GetThisDrawing(path, "");
  27. if (doc_as != null)
  28. {
  29. acd.GetEntityReference(doc_as);
  30. }
  31. acd.Dispose();
  32. }
  33. catch (System.Exception ac)
  34. {
  35. Console.WriteLine(ac);
  36. throw;
  37. }
  38. }
  39. }
  40. }