关于autocad的二次开发!!
[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都直接挂了!!!说出现致命错误!高手救救火啊!!
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都直接挂了!!!说出现致命错误!高手救救火啊!!
...全文
相关推荐
基于C#.NET的Autocad二次开发范例
在AutoCAD的二次开发中,C#主要通过.NET Framework的AutoCAD .NET API来实现。
【C#】AutoCAD二次开发笔记
一、环境 本人使用的IDE为VS2017,CAD为AutoCAD2019,在建立项目的时候需要注意Framework版本的选择,由于CAD为2019,对应的Framework为4.7,而Visual Sti在导入以下三个库后:
AutoCAD软件二次开发:AutoCAD二次开发之Python编程
pyautocad库是Python与AutoCAD交互的主要工具。它提供了对AutoCAD对象模型的访问,允许开发者创建、修改和查询AutoCAD图形。AutoCAD对象模型(Object Model)是AutoCAD提供的一种编程接口,它允许开发者通过编程语言访问和控制AutoCAD的内部对象和功能。在Python中,我们可以通过pyautocad库来实现这一目标,该库提供了与AutoCAD对象模型交互的Python接口。AutoCAD对象模型的核心是其层次结构,从最顶层的。
AUTOCAD C#二次开发
### AUTOCAD C#二次开发知识点总结#### 一、AUTOCAD二次开发概述- **定义**: AUTOCAD二次开发是指在AUTOCAD的基础上,利用AUTOCAD提供的API接口或者开发工具
AutoCAD二次开发的方法与实例.pdf
#### 关键词:VBA;AutoCAD;二次开发;ActiveX#### 一、AutoCAD二次开发背景及意义AutoCAD因其强大的交互功能和图形处理能力而被广大工程技术人员所青睐。


