andresperezcera 发表于 2022-7-6 08:01:47

没有LISP测试t的经验

就在几分钟前,我找到了这组VBA和Lisp代码来指定命名页面设置。然而,它总是向我返回错误:
 
(P设置“PDF分类账”);错误:无函数定义:PSETUP
 
这是我找到的箱子,有人能帮我吗?
 

Dim PageSetup As String
PageSetup = """LargeDoc 24x36{24x36}""": ThisDrawing.SendCommand "(psetup " & PageSetup & ") "


Heres the Lisp code:
ALL CREDITS OF THE LISP HAVE REMAINED.

; Jason Piercey . May 16th, 2003
; assign a pagesetup to a layout
; - string, layout name
; - string, pagesetup to assign
; return: T or nil
; modified by chris castelein 10-31-05
; to pass paper size as an argument.
; original prompt code left in and remarked out.
(defun putPagesetup (layout setup / layouts plots)
(defun item-p (collection item)
(if
(not
(vl-catch-all-error-p
(vl-catch-all-apply
'(lambda () (setq item (vla-item collection item))))))
item
)
)
(and
(or *acad* (setq *acad* (vlax-get-acad-object)))
(or *doc* (setq *doc* (vla-get-activedocument *acad*)))
(setq layouts (vla-get-layouts *doc*))
(setq plots (vla-get-plotconfigurations *doc*))
(setq layout (item-p layouts layout))
(setq setup (item-p plots setup))
(not (vla-copyfrom layout setup))
)
)
(defun massoc (key alist / x nlist)
(foreach x alist
(if (eq key (car x))
(setq nlist (cons (cdr x) nlist))
)
)
(reverse nlist)
)

; Return: list of all pagesetups defined in the current drawing or nil
(defun getPagesetups ()
(massoc 3 (dictsearch (namedobjdict) "Acad_PlotSettings"))
)
; Jason Piercey . May 19th, 2003
; assign pagesetup to layout(s)
; LIMITED testing
; written for Shawn McDonald
(defun psetup (page / lst res)
(setq lst (mapcar 'strcase (getPagesetups)))
(while (not page)
;(setq page (strcase (getstring T "\nspecify pagesetup to apply: ")))
(if (or (= "" page) (not (member page lst)))
(progn (princ "\npagesetup not found") (setq page nil))
)
)
(initget "All Current")
;(if(not(setq res (getkword "\napply pagesestup to which layout(s) <all>: ")))
;(setq res "All")
(setq res "Current")

(if (= "All" res)
(foreach x (vl-remove "Model" (layoutlist)) (putPagesetup x page))
(putPagesetup (getvar "ctab") page)
)
(princ "\nFinished")
(princ)
)

MSasu 发表于 2022-7-6 08:38:11

PSETUP的定义可以在摘录中找到,但在VBA调用时似乎没有加载。尝试将AutoLISP代码添加到您的启动套件中;然后,在那里定义的功能将在每个图形中可用。
请注意,从VBA调用AutoLISP例程可能非常棘手。

andresperezcera 发表于 2022-7-6 08:48:23

问题是我甚至不知道怎么做。请帮帮我。我甚至不知道如何从命令栏调用该函数。

MSasu 发表于 2022-7-6 09:06:36

请查看这些教程(由Lee Mac编写):
[列表]
[*]如何运行AutoLISP程序
[*]自动加载程序
[/列表]
页: [1]
查看完整版本: 没有LISP测试t的经验