[英]Working with autocad in c#
有什么方法可以通過使用Autodesk.Autocad.Interop
和Autodesk.Autocad.Interop.common
dll在C#中以編程方式在繪圖中插入一種圖像文件(例如png或jpg) ?
我已經嘗試過AcadDocument.Database.ModelSpace.InsertBlock()
但它僅適用於dwg文件,並為圖像返回以下錯誤:
“無效的文件頭。”
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。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.