是否可以通过Autodesk.Autocad.Interop
和{{}以编程方式在c#中插入一种图像文件,例如 png 或 jpg 到图形中1}} dll?
我已尝试过Autodesk.Autocad.Interop.common
但它只适用于dwg文件并为图像返回以下错误:
“文件标头无效。”
答案 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。