GregGleason 发表于 2022-7-5 15:25:15

理论新绘图问题

是否可以使用lisp打开新图形并引用模板?
 
格雷格

rlx 发表于 2022-7-5 15:58:35

漫长的白天,短暂的夜晚,所以只有时间再多讲一个睡前小故事
 
 
 
https://jtbworld.com/autolisp-visual-lisp
 

; This is how you can do a PGP file reinitialization (reload)awing template file used by QNEW
;;; (ax:GetQnewPath)
(defun ax:GetQnewPath (/ prof key)
(setq prof (vla-get-ActiveProfile (vla-get-profiles (vla-get-preferences (vlax-get-Acad-Object)))))
(setq key (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" prof "\\General"))
(vl-registry-read key "QnewTemplate")
)
;;; Set the drawing template file used by QNEW
;;; This writes it to the registry but is later dismissed and overwritten by AutoCAD
;;; (ax:SetQnewPath "M:\\CAD\\ACADISO.DWT")
(defun ax:SetQnewPath (QnewPath / prof key)
(setq prof (vla-get-ActiveProfile (vla-get-profiles (vla-get-preferences (vlax-get-Acad-Object)))))
(setq key (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" prof "\\General"))
(vl-registry-write key "QnewTemplate" QnewPath)
)
;; Gets current template
(getenv "QnewTemplate")
"c:\\my files\\templates\\qnew.dwt"
and
;; Sets a different template
(setenv "QnewTemplate" "")

Lee Mac 发表于 2022-7-5 16:19:29

(vla-add (vla-get-documents (vlax-get-acad-object)) "YourTemplate.dwt")

GregGleason 发表于 2022-7-5 16:36:27

 
哇!简单但优雅。我试试看。谢谢李。
 
格雷格
页: [1]
查看完整版本: 理论新绘图问题