关于AutoCADConnector这个程序的问题

大屏幕 2008-03-15 11:56:46
using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
using System.Runtime.InteropServices;

namespace SPMP.BomEditTool
{
public class AutoCADConnector : IDisposable
{
private AcadApplication _application;

private bool _initialized;

private bool _disposed;


public AutoCADConnector()
{
try
{
//Upon creation,attempt to retrieve running instance
_application = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application.17");
}
catch
{
try
{
//Create an instance and set flag to indicate this
_application = new AcadApplicationClass();

_application.Visible = true;

_initialized = true;
}
catch
{
throw;
}
}
}
//If the user doesn't call Dispose, the
//garbage collector will upon destruction

~AutoCADConnector()
{
Dispose(false);
}

public AcadApplication Application
{
get
{
//return our internal instance of autocad
return _application;
}
}

//This is the user-callable version of Dispose.
//It calls our internal version and removes the
//object from the garbage collector's queue.

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

//this version of Dispose gets called by our
//destructor

protected virtual void Dispose(bool disposing)
{
//if we create our Autocad instance, call its
//Quit method to avoid leaking memory.
if (!this._disposed && _initialized)
_application.Quit();

_disposed = true;
}


}

}

有没有人用过AutoCADConnector网上的这个程序,我用 (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application.17.1") 读取当前的autocad对象时,为什么当我同时打开多个autocad进程,只能读取第一个打开的autocad中的图形文件,而我想读取的是最后打开的 autocad中的图形文件。谁解决过这个问题?
...全文
194 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,451

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计/Flash/Silverlight 开发 图象工具使用
社区管理员
  • 图象工具使用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧