在c#中使用autocad

时间:2014-03-08 10:52:20

标签: c# autocad

是否可以通过Autodesk.Autocad.Interop和{{}以编程方式在c#中插入一种图像文件,例如 png jpg 到图形中1}} dll?

我已尝试过Autodesk.Autocad.Interop.common但它只适用于dwg文件并为图像返回以下错误:

“文件标头无效。”

1 个答案:

答案 0 :(得分:3)

InsertBlock()仅用于插入块定义。使用AddRaster()通过AutoCAD Interop库导入图像:

var imgPath = @"C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg";
var imgScale = 2.0;
var imgRot = (Math.PI / 180) * 90;
var imgPoint = new double[] {1, 1, 0};

doc.ModelSpace.AddRaster(imgPath, imgPoint, imgScale, imgRot);

其中'doc'是正在运行的AutoCAD会话的ActiveDocument。