问题描述:

在打印过程中开发者有时会遇到大部分打印出图的dwg是正常的,而有少数dwg打印空白或者偏移问题,应该如何解决?

原因分析

可能是图纸的DCS与WCS不一致,而二次开发程序没有对打印区域的坐标进行转换,直接使用了WCS坐标

解决方案:

方法1:

  1. 打开打印结果错误的图纸
  2. 将 Target 系统变量的值设置为 0,0,0

方法2:

如果使用窗口范围打印,请检查传入的窗口坐标点是否有转换到DCS坐标系下。以下为示例代码:

C++

	ads_point pt, result; 
    struct resbuf fromrb, torb; 
    pt[X] = 1.0; 
    pt[Y] = 2.0; 
    pt[Z] = 3.0; 
    fromrb.restype = RTSHORT; 
    fromrb.resval.rint = 0; // WCS  
    torb.restype = RTSHORT; 
    torb.resval.rint = 2; // DCS  
    // disp == 0 indicates that pt is a point:  
    acedTrans(pt, &fromrb, &torb, FALSE, result);


C#

	// 该函数仅在中望CAD 2025以后的版本支持
    Point3d dcsPt = ZwSoft.ZwCAD.Internal.Utils.UcsToDisplay(ucsPt, false); 
    
    // 中望CAD 2024及以前的版本请导入ZRX接口
    [DllImport("zwcad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "zcedTrans")]
    static extern int zcedTrans(double[] point, IntPtr from, IntPtr to, int disp, double[] result);    
    public void TransCoord() 
    {
        double[] pt = new double[] { 0, 0, 0 };
        double[] result = new double[] { 0, 0, 0 };
        ResultBuffer from = new ResultBuffer(new TypedValue(5003, 0));
        ResultBuffer to = new ResultBuffer(new TypedValue(5003, 2));
        zcedTrans(pt, from.UnmanagedObject, to.UnmanagedObject, 0, result);
    }


VBA

	Dim dcsPt As Variant
    dcsPt = ThisDrawing.Utility.TranslateCoordinates(wcsPt, zcWorld, zcDisplayDCS, False)

方法3:

Target值不为0,0,0时对打印数据做偏移

C#示例

                    // 获取当前视图
                    ViewTableRecord vtr = (ViewTableRecord)doc.Editor.GetCurrentView();
                    Point3d target = vtr.Target;
                    Point3d dcsPt = ZwSoft.ZwCAD.Internal.Utils.UcsToDisplay(pt, false) - target.GetAsVector();
                    Point3d dcsPt1 = ZwSoft.ZwCAD.Internal.Utils.UcsToDisplay(pt1, false) - target.GetAsVector();

                    psv.SetPlotType(ps, ZwSoft.ZwCAD.DatabaseServices.PlotType.Window);
                    psv.SetPlotWindowArea(ps,new Extents2d(new Point2d(dcsPt.X, dcsPt.Y),new Point2d(dcsPt1.X, dcsPt1.Y)));


英文空间链接


★★在中望CAD中使用二次开发程序进行打印时,打印结果空白或打印的区域不是指定的区域,如何解决?https://confluence.zwcad.com/pages/viewpage.action?pageId=284952166

  • No labels