关于autocad的二次开发!!

will_chen891010 2009-08-30 08:57:16
[CommandMethod("cre")]
public void cre()
{
int i,j;
MText mt = new MText();

TypedValue[] ty = new TypedValue[] { new TypedValue((int)DxfCode.Text,mt) };
SelectionFilter sel = new SelectionFilter(ty);
SelectionFilter fil = new SelectionFilter(ty);
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptSelectionOptions re = new PromptSelectionOptions();
PromptSelectionResult su = ed.GetSelection(re );
if (su.Status != PromptStatus.OK)
{
return;
}
Autodesk.AutoCAD.EditorInput.SelectionSet SS = su.Value;
ObjectId[] idArray;
idArray = SS.GetObjectIds();
i = idArray.Length;
StreamWriter strw = File.CreateText("d:\\temp\\Mmmmtest.txt");
strw.WriteLine(i.ToString());


for (j = 0; j <= i - 1; j++)
{
//try
//{
if (idArray[j].GetObject(OpenMode.ForRead).GetType() is MText)
{


mt = (MText)idArray[j].GetObject(OpenMode.ForRead);
strw.WriteLine(mt.Contents.ToString());
}
else
{
continue;
}





}
strw.Close();


}
这编译都通过了,是关于autocad的二次开发的,目的是将text读取到txt文件中!!但是一再cad中用连autocad都直接挂了!!!说出现致命错误!高手救救火啊!!
...全文
150 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jhdxhj 2009-09-01
  • 打赏
  • 举报
回复
ding
xu_2007 2009-09-01
  • 打赏
  • 举报
回复
你这是在读扩展数据吗?还是每个对象上的文本?如果只是读一般的数据不需要这么长的代码
flyerwing 2009-09-01
  • 打赏
  • 举报
回复
学习!
yankunlin 2009-08-30
  • 打赏
  • 举报
回复
学习..........
wuyq11 2009-08-30
  • 打赏
  • 举报
回复

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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