问题:.NET进行打印设置为窗口打印的时候,导致框选的区域不能正常打印,设置和CAD原生一样。
查看了帮助文档,各种社区,没有一条有用的信息,没办法,瞎蒙吧,把所有打印设置都试了一遍之后,
想到了坐标系转换,然后查阅国外资料发现打印的坐标系是DCS,而选取的extents是在UCS里的
好吧,算是找到了曙光了!
然后发现~从UCS转DCS,又恰了……
UCS需要先转WCS,然后从WCS转DCS
第一步UCS TO WCS
point.TransformBy(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.CurrentUserCoordinateSystem);
妥妥的
然后第二部复杂一点:
// 将 WCS 坐标变换为 DCS 坐标
Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
ViewTableRecord acView = acDoc.Editor.GetCurrentView();
Matrix3d matWCS2DCS;
matWCS2DCS = Matrix3d.PlaneToWorld(acView.ViewDirection);
matWCS2DCS = Matrix3d.Displacement(acView.Target - Point3d.Origin) * matWCS2DCS;
matWCS2DCS = Matrix3d.Rotation(-acView.ViewTwist, acView.ViewDirection, acView.Target) * matWCS2DCS;
Extents3d extent = new Extents3d(pt1, pt2);
matWCS2DCS = matWCS2DCS.Inverse();
extent.TransformBy(matWCS2DCS);
由于是使用的窗口要初始化EXTENTS所以需要对于点的大小进行下处理,不然框选的起点和终点不同会对于初始化有问题哦