获取所有文档出错?
本帖最后由 cdinten 于 2012-6-26 16:07 编辑直接上代码:
///<summary>
/// 获取所有打开的文档
///<summary>
public static Document[] GetAllDrawings()
{
try
{
DocumentCollection DocColl = Application.DocumentManager;
Document[] docArr = null;
DocColl.CopyTo(docArr, 0);
return docArr;
}
catch (System.Exception exc)
{
Application.ShowAlertDialog(exc.Message);
}
return null;
}
不知道是怎么回事?是不是ACAD的API中实现CopyTo有问题啊?另外获取活动文档数目的属性 Application.DocumentManager.Count也有问题,我使用的是AutoCAD2008。
CommandMethod的函数有返回值? <CommandMethod("GetAllDrawings")> Public Sub GetAllDrawings()
Dim DocColl As DocumentCollection = Application.DocumentManager
Dim docArr() As Document
Dim i As Integer = 0
Dim ent As Document
ReDim docArr(DocColl.Count - 1)
For Each ent In DocColl
docArr(i) = ent
i = i + 1
Next
End Sub
我是这样做的,能获取所有的文档
页:
[1]