CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

SetWindowToPlot Method (ActiveX)

2023-1-4 00:58| 发布者: admin| 查看: 503| 评论: 0|来自: AutoCAD

摘要: 设置定义要打印的布局部分的坐标。

设置定义要打印的布局部分的坐标。

支持的平台:仅窗口

签名

工 务 局:

object.SetWindowToPlot LowerLeft, UpperRight
对象

类型:布局绘图配置

此方法适用的对象。

左下角

访问:仅输入

类型:变体(双精度的双元素数组)

左下角窗口的XY值。

右上

访问:仅输入

类型:变体(双精度的双元素数组)

右上角窗口的XY值。

返回值(RetVal)

无返回值。

言论

窗口坐标取自原点。

这些值的单位由属性指定。PaperUnits

必须设置属性才能将这些坐标用于绘图。PlotTypeacWindow

例子

工 务 局:

Sub Example_SetWindowToPlot()
    ' This example allows the user to define an area in the current layout
    ' and displays a plot preview of the defined area.
    '
    ' * Note: You have to exit the
    ' plot preview before the VBA example will stop and control will be returned

    AppActivate ThisDrawing.Application.Caption

    Dim point1 As Variant, point2 As Variant
    
    ' Get first point in window
    point1 = ThisDrawing.Utility.GetPoint(, "Click the lower-left of the window to plot.")
    ReDim Preserve point1(0 To 1)   ' Change this to a 2D array by removing the Z position
    
    ' Get second point in window
    point2 = ThisDrawing.Utility.GetPoint(, "Click the upper-right of the window to plot.")
    ReDim Preserve point2(0 To 1)   ' Change this to a 2D array by removing the Z position
    
    ' Send information about window to current layout
    ThisDrawing.ActiveLayout.SetWindowToPlot point1, point2
    
    ' Read back window information
    ThisDrawing.ActiveLayout.GetWindowToPlot point1, point2
    
    MsgBox "Press any key to plot the following window:" & vbCrLf & vbCrLf & _
           "Lower Left: " & point1(0) & ", " & point1(1) & vbCrLf & _
           "Upper Right: " & point2(0) & ", " & point2(1)
    
    ' Be sure to plot a view, not some other plot style
    ThisDrawing.ActiveLayout.PlotType = acWindow
    
    ' Send Plot To Window
    ThisDrawing.ActiveLayout.ConfigName = "DWG to PDF.pc3"
    ThisDrawing.Plot.DisplayPlotPreview acFullPreview
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_SetWindowToPlot()
    ;; This example allows the user to define an area in the current layout to plot
    ;; and displays a plot preview of the defined area.
    ;;
    ;; * Note: You will have to exit the plot preview
    ;;  before the VBA example will stop and control will be returned
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

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

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

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

    (setq point1 (vlax-safearray->list point1)
	         point2 (vlax-safearray->list point2))
  
    (alert (strcat "Press any key to plot the following window:"
                   "\nLower Left: " (rtos (nth 0 point1) 2) ", " (rtos (nth 1 point1) 2)
                   "\nUpper Right: " (rtos (nth 0 point2) 2) ", " (rtos (nth 1 point2) 2)))
    
    ;; Make sure the instruction is to plot a view, not some other plot style
    (vla-put-PlotType (vla-get-ActiveLayout doc) acWindow)
    
    ;; Send Plot To Window - A plot device must be set before a preview can be created
    (vla-put-ConfigName (vla-get-ActiveLayout doc) "DWG to PDF.pc3")
    (vla-DisplayPlotPreview (vla-get-Plot doc) acFullPreview)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-12 06:14

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部