明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2480|回复: 5

[提问] 求解决用vla-SetWindowToPlot打印时坐标偏移的问题

[复制链接]
发表于 2017-12-5 16:09:41 | 显示全部楼层 |阅读模式
这几天有空,想着把在用的批量打印程序修改下,之前用的是command plot,打算改成vl函数。
差不多改完的时候,在用旧图测试的时候,发现一个问题,有部分旧图的打印定位点发生了偏移。
检查了好几遍都没发现代码有什么问题,然后用CAD帮助文件里的示例程序测试了下,发现存在同样的情况。
示例程序代码如下。运行后,提示框里的坐标都是对的,但之后的预览就出现问题。检查发现,pointTemp1、pointTemp2这两个参数的坐标值,与vla-SetWindowToPlot及vla-GetWindowToPlot之后提取的point1、point2也都一致。但不知道为啥,最后预览或者打印出来就会出问题。

附件中的dwg分别是用有问题和正常的旧图,删除所有内容后,放了同一个图框,并清理了一遍。
两个dwg,基本上是一样的了,但不知道为啥,有问题的那个预览就是会偏移,另一个就是正常的。
求教,是不是还是什么参数要进行控制?

  1. (defun c:Example_SetWindowToPlot( / acadObj doc point1 pointTemp1 point2 pointTemp2)
  2.     ;; This example allows the user to define an area in the current layout to plot
  3.     ;; and displays a plot preview of the defined area.
  4.     ;;
  5.     ;; * Note: You will have to exit the plot preview
  6.     ;;  before the VBA example will stop and control will be returned
  7.     (setq acadObj (vlax-get-acad-object))
  8.     (setq doc (vla-get-ActiveDocument acadObj))

  9.     ;; Get first point in window
  10.     (setq point1 (vlax-variant-value (vla-GetPoint (vla-get-Utility doc) nil "Click the lower-left of the window to plot.")))

  11.     ;; Change this to a 2D array by removing the Z position
  12.     (setq pointTemp1 (vlax-make-safearray vlax-vbDouble '(0 . 1)))
  13.     (vlax-safearray-put-element pointTemp1 0 (vlax-safearray-get-element point1 0))
  14.     (vlax-safearray-put-element pointTemp1 1 (vlax-safearray-get-element point1 1))
  15.    
  16.     ;; Get second point in window
  17.     (setq point2 (vlax-variant-value (vla-GetCorner (vla-get-Utility doc) point1 "Click the upper-right of the window to plot.")))

  18.     ;; Change this to a 2D array by removing the Z position
  19.     (setq pointTemp2 (vlax-make-safearray vlax-vbDouble '(0 . 1)))
  20.     (vlax-safearray-put-element pointTemp2 0 (vlax-safearray-get-element point2 0))
  21.     (vlax-safearray-put-element pointTemp2 1 (vlax-safearray-get-element point2 1))
  22.    
  23.     ;; Send information about window to current layout
  24.     (vla-SetWindowToPlot (vla-get-ActiveLayout doc) pointTemp1 pointTemp2)
  25.    
  26.     ;; Read back window information
  27.     (vla-GetWindowToPlot (vla-get-ActiveLayout doc) 'point1 'point2)

  28.     (setq point1 (vlax-safearray->list point1)
  29.           point2 (vlax-safearray->list point2))
  30.   
  31.     (alert (strcat "Press any key to plot the following window:"
  32.                    "\nLower Left: " (rtos (nth 0 point1) 2) ", " (rtos (nth 1 point1) 2)
  33.                    "\nUpper Right: " (rtos (nth 0 point2) 2) ", " (rtos (nth 1 point2) 2)))
  34.    
  35.     ;; Make sure the instruction is to plot a view, not some other plot style
  36.     (vla-put-PlotType (vla-get-ActiveLayout doc) acWindow)

  37.     ;; Send Plot To Window - A plot device must be set before a preview can be created
  38.     (vla-put-ConfigName (vla-get-ActiveLayout doc) "DWG To PDF.pc3")
  39.     (vla-DisplayPlotPreview (vla-get-Plot doc) acFullPreview)
  40. )


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2017-12-5 23:27:38 来自手机 | 显示全部楼层
视点偏移  估计 参数名忘了  搜下 “cad 视点”
发表于 2017-12-5 23:34:38 来自手机 | 显示全部楼层
target  ,,,,,,
 楼主| 发表于 2017-12-6 09:37:56 | 显示全部楼层
masterlong 发表于 2017-12-5 23:34
target  ,,,,,,

感谢,确实视点的关系。
发表于 2017-12-10 09:48:30 | 显示全部楼层
转换成dcs即可。可以避免这样因为target非标的情况。
 楼主| 发表于 2017-12-12 13:46:44 | 显示全部楼层
edata 发表于 2017-12-10 09:48
转换成dcs即可。可以避免这样因为target非标的情况。

试了下,用(trans p 0 2)转化的点也可以解决问题,多谢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-19 21:26 , Processed in 0.168920 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表