有关一个C# autocad 二次开发的问题
导入 acdbmgd 和 acmgb 两个cad类库文件,想往 cad 里插入一条直线.程序采用的是传统winform结构(非WPF)
代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
namespace CAD_Excel_Library
{
public static class CAD_Excel_Library
{
[CommandMethod ("AddLine")]
public static void AddLineCmd()
{
using (Database db = HostApplicationServices.WorkingDatabase)//获得当前工作空间的数据库
{
using (BlockTable bt = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForRead))//获得块表
{
using (BlockTableRecord btr = (BlockTableRecord)bt[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForWrite))//获得模型空间的块表记录
{
Line line = new Line(new Point3d(0, 0, 0), new Point3d(200, 200, 0));//创建一条直线
line.Color = Autodesk.AutoCAD.Colors.Color.FromColor(System.Drawing.Color.Red);
btr.AppendEntity(line);//将直线添加到模型空间中
}
}
}
}
}
}
一直报错: 组件"Autodesk.AutoCAD.AcInfoCenterConn.MyAutoCADBalloon"不具有由 URI "/AcWindows:component/infocenteracconn/myautocadballoon.xaml"识别的资源..