newer 发表于 2025-5-14 19:25:00

XD::PLOT:GetPlotToFilePath




;; ------------------------------------------------------------------------
;;; 函数名称 / function name: XD::PLOT:GetPlotToFilePath
;;;
;;; 【功能说明 / description】
;;;   获取 AutoCAD 中的默认“打印到文件”输出路径。
;;;   使用错误捕获机制(vl-catch-all-apply)防止访问失败时中断程序。
;;;   成功时返回路径字符串,失败返回 NIL。
;;;
;;; 【参数说明 / parameters】
;;;   无参数。
;;;
;;; 【返回值 / return value】
;;;   字符串 - 成功时返回默认输出路径
;;;   NIL    - 获取失败(如未能访问 Preferences 对象)
;;;
;;; 【示例 / example】
;;;   (XD::PLOT:GetPlotToFilePath)
;; ------------------------------------------------------------------------

(defun XD::PLOT:GetPlotToFilePath (/ preferences output)
(vl-catch-all-error-p
    (setq output
      (vl-catch-all-apply
      'vla-get-DefaultPlotToFilePath
      (list
          (vla-get-Output
            (vla-get-Preferences
            (vlax-get-acad-object)
            )
          )
      )
      )
    )
)
;; 如果 output 是错误对象,返回 nil,否则返回路径
(if (vl-catch-all-error-p output)
    nil
    output
)
)




happyending 发表于 2025-7-20 10:29:47

学习一下代码是怎样工作的。感谢分享。
页: [1]
查看完整版本: XD::PLOT:GetPlotToFilePath