Jump to content

No experience in LISP trying to figure it out.


Recommended Posts

Posted

Just a few minutes ago, I found this set of both VBA and Lisp code to assign named page setups. However it is always returning me the error:

 

(psetup "PDF LEDGER") ; error: no function definition: PSETUP

 

Here is the coude I found, could someone help me?

 

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
; [layout] - string, layout name
; [setup] - 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 "\n[All/Current]apply 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)
)

Posted

The definition of PSETUP is available in your excerpt, but seems to don't be loaded when called by VBA. Try to add that AutoLISP code to your start-up suite; then the functions defined there will be available in each drawing.

Please pay attention that calling AutoLISP routines from VBA can be very tricky.

Posted

The thing is i don't even know how to do that. Please help me. I don't even know how to call that function from command bar.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...