import page setup from one existing drawing to a new drawing

import page setup from one existing drawing to a new drawing

mruPRQUJ
Advocate Advocate
663 Views
7 Replies
Message 1 of 8

import page setup from one existing drawing to a new drawing

mruPRQUJ
Advocate
Advocate

Hi there,

 

Is it possible to create a lisp to import page setup from one existing drawing to a new drawing? thank you very much in advance! 🙂

0 Likes
Accepted solutions (1)
664 Views
7 Replies
Replies (7)
Message 2 of 8

CodeDing
Advisor
Advisor

EDIT:

My original reply was to import a LAYOUT from another drawing. I misread since OP wants a PAGE SETUP from another dwg

Message 3 of 8

LDShaw
Collaborator
Collaborator

Pretty sure I sent you this. You marked that one as answered so I did not bother doing more. 

Here 

 

 

 (command "._-PSETUPIN" "x:\\xx\\Page Setups.dwg" "3624 PDF")

 

 

 Is the dwg your pulling from 
3624 pdf is the plot setup.

(if (= (strcase "3624 PDF") (strcase (vla-get-name x)))

puts the 3624 pdf as the page setup.

;;; ==============================================================================
;;; Lisp Name: foo.lsp
;;; Author: Lonnie
;;; Date Created: 2024-07-02
;;; Last Edited: [Insert Last Edit Date]
;;;
;;; DESCRIPTION:
;;; A routine to set up page configurations by importing them from a specified DWG file.
;;;
;;; Usage:
;;; 1. Load the Lisp routine.
;;; 2. Run the command "foo" in AutoCAD.
;;;
;;; Parameters:
;;; None explicitly, but internally uses the DWG path and page setup name.
;;;
;;; Returns:
;;; None
;;;
;;; Notes:
;;; - This routine imports the "3624 PDF" page setup from the specified DWG file 
;;;   ("x:\\xx\\Page Setups.dwg") and applies it to the current drawing.
;;;
;;; Related URL:
;;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/copy-objects-in-one-dwg-files-with-lots-of-layouts-sheets/td-p/12949888
;;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-a-page-setup-current-with-lsp/td-p/12917953
;;;
;;; ---------------------------- Main Program --------------------------------

(defun C:foo ()
  (command "._-PSETUPIN" "x:\\xx\\Page Setups.dwg" "3624 PDF")
  (vlax-for x
    (vla-get-plotconfigurations
      (setq d (vla-get-activedocument (vlax-get-acad-object))))
    (if (= (strcase "3624 PDF") (strcase (vla-get-name x)))
      (vl-catch-all-apply 'vla-copyfrom (list (vla-get-activelayout d) x))
    )
  )
)




Message 4 of 8

mruPRQUJ
Advocate
Advocate

Yes, the dwg is my pulling from 3624 pdf the plot setup. 

It did not work. Could you please provide some advice to me? Could be the path wrong? Many thanks.

The information is below for your reference:

FOO
._-PSETUPIN Enter file name: C:UUsersmruDesktopBLOCKSPage Setups.dwg
"UUsersmruDesktopBLOCKSPage Setups.dwg": Can't find file.
Command: 3624 PDF Unknown command "3624 PDF". Press F1 for help.

 

My Lisp is below:

(defun C:foo ()
(command "._-PSETUPIN" "C:\Users\mru\Desktop\BLOCKS\Page Setups.dwg" "3624 PDF")
(vlax-for x
(vla-get-plotconfigurations
(setq d (vla-get-activedocument (vlax-get-acad-object))))
(if (= (strcase "3624 PDF") (strcase (vla-get-name x)))
(vl-catch-all-apply 'vla-copyfrom (list (vla-get-activelayout d) x))
)
)
)

0 Likes
Message 5 of 8

LDShaw
Collaborator
Collaborator
Accepted solution

Try this,

(defun C:foo ()
(command "._-PSETUPIN" "C:\\Users\\mru\\Desktop\\BLOCKS\\Page Setups.dwg" "3624 PDF")
(vlax-for x
(vla-get-plotconfigurations
(setq d (vla-get-activedocument (vlax-get-acad-object))))
(if (= (strcase "3624 PDF") (strcase (vla-get-name x)))
(vl-catch-all-apply 'vla-copyfrom (list (vla-get-activelayout d) x))
)
)
)

If it does not work copy this in. 

(defun C:listPageSetups ()
(setq d (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for x (vla-get-plotconfigurations d)
(princ (strcat "\nPage Setup: " (vla-get-name x)))
)
(princ)
)

Message 6 of 8

mruPRQUJ
Advocate
Advocate

It works great now. Could you please advise me if the "foo" can be changed to others? how to change it? I have one lisp with "foo", thanks a lot! 🙂

0 Likes
Message 7 of 8

LDShaw
Collaborator
Collaborator

Nothing mysterious (defun C:foo () can be anyting you like. (defun C:hey ()
Would work just as well. Any simple editor will work. Just remember to save the file type to lsp

Message 8 of 8

mruPRQUJ
Advocate
Advocate

Thanks a million!

Have a wonderful day! 🙂

0 Likes