这里只是片断,前后都省略了,虽然我并不清楚你需要实现什么,这段代码也许对你有参考价值。- …… (vla-getpapersize clayout 'pWidth 'pHeight)
- ;; 取得当前纸张的长边长度
- (if (< pwidth pheight)
- (setq paperWidth pHeight)
- (setq paperwidth pWidth)
- )
- (if (and (= mode "FILE") (= "1" (getvalue 'DeletePlotFile)))
- (foreach pltfile (GetPlotFileList)
- (princ "\n删除已有打印文件:")
- (princ (strcat (getvalue 'PlotFileFolder) pltfile))
- (vl-file-delete (strcat (getvalue 'PlotFileFolder) pltfile))
- )
- )
- ;; 对每个图框循环
- (foreach bounding bdlist
- (vla-put-paperunits clayout acMilliMeters)
- ;;(vla-put-plotorigin clayout (ax:2dpoint '(0 0)))
- ;; 设置打印方向
- (if (= (islandscape bounding) (> pWidth pHeight))
- (vla-put-plotrotation clayout ac0degrees)
- (vla-put-plotrotation clayout ac90degrees)
- )
- ;; 设置打印范围
- (vla-SetWindowToPlot
- clayout
- (ax:2dpoint (car bounding))
- (ax:2dpoint (cadr bounding))
- )
- ;; (apply 'vl-cmdf (cons "rectang" bounding))
- ;; 设置打印方式为window
- (vla-put-plottype clayout acWindow)
- ;; 设置打印比例
- (cond ((= plotscale "ScaleToFit")
- (progn (vla-put-standardscale clayout acScaleToFit)
- (princ "\n当前打印比例: 适合可打印区域\n")
- )
- )
- ((= plotscale "Auto")
- (progn (setq scale (fix (+ 0.5 (/ (getwidth bounding) paperwidth))))
- (vla-put-standardscale clayout acVpCustomScale)
- (vla-setcustomscale clayout 1 scale)
- (princ "\n当前打印比例 = 1:")
- (princ scale)
- (princ "\n")
- )
- )
- ('T
- (progn (vla-put-standardscale clayout acVpCustomScale)
- (vla-setcustomscale clayout 1 plotscale)
- (princ "\n当前打印比例 = 1:")
- (princ plotscale)
- (princ "\n")
- )
- )
- )
- ;; 设置自动居中打印
- (vla-put-centerplot clayout :vlax-true)
- ;; 打印或览
- (cond ((= mode "PLOT")
- (progn
- (princ "\n打印份数: ")
- (princ (getvalue 'Copies))
- (princ "\n")
- (vla-put-NumberofCopies plot (read (getvalue 'Copies)))
- (if (= :vlax-false (vla-plotToDevice plot))
- (exit)
- )
- )
- )
- ((= mode "PREVIEW")
- (if (= :vlax-false (vla-displayplotpreview plot acfullpreview))
- (exit)
- )
- )
- ((= mode "FILE")
- (progn (setq pltfilebaselist (mapcar 'vl-filename-base (GetPlotFileList)))
- (setq plotfile (GetNewAutoNumName (getvalue 'PlotFilePrefix) 2 pltfilebaselist))
- (setq plotfile (strcat (GetValue 'PlotFileFolder) plotfile ".plt"))
- (princ "\n生成打印文件: ")
- (princ plotfile)
- (princ "\n")
- (vla-plottofile plot plotfile)
- )
- )
- )
- (if (and (= mode "PREVIEW") (/= bounding (last bdlist)))
- (progn (initget "Yes No")
- (setq key (getkword "是否继续预览下一张? [Yes/No]<Yes>"))
- (if (= key "No")
- (exit)
- )
- )
- )……
|