Does anyone in the group know of a lisp routine available out there that will import a page setup in multiple drawings in one shot and save it to the group of drawings? Kind of the way you can import a page setup in a group of drawings in Publish, but that's only temporary for that particular print job. I'm looking for something that will permanently save it to the list of drawings.
Thanks in advance.
M.
Hi,
Here is an article from the Autodesk Developer Network knowledge base. It is not a complete solution but it shows how you can use the API to import a PageSetup.
>> >> >>
Visual LISP: Importing PageSetups from another drawing?
Issue
Is there an ActiveX alternative to (command "._PSETUPIN" file name) in Visual LISP? I want to import plot configurations from another drawing.
Solution
While this technique takes longer to run than (command " -PSETUPIN" ), the following example demonstrates how to use the (vla-CopyFrom) method to import pagesetups.
NOTE: This example assumes that a PaperSpace pagesetup named "MyEPlotTest" exists in a drawing named "MyPageSetups.dwg". Also run this code in a non production drawing as it deletes all page setups. The example can be modified so that it would not try to import a PageSetup into a drawing that already has a PageSetup named "MyEPlotTest".
(vl-load-com)
(setq *doc* (vla-get-activedocument (vlax-get-acad-object)))
(defun ImpPgSetups (psname / psfile doc2 colPgSetups1 colPgSetups2
objPgSetup objPgSetup2 sName)
(if (setq psfile (findfile "MyPageSetups.dwg")) ; if page setup source file is found,
(progn
;; delete all existing page setups.
(DelPgSetups)
;; import page setups
(setq doc2 (vla-open (vla-get-documents (vlax-get-acad-object)) psfile)
colPgSetups1 (vla-get-PlotConfigurations *doc*)
colPgSetups2 (vla-get-PlotConfigurations doc2)
) ;setq
;;get each page setup in the ACAD_PLOTSETTINGS dictionary
(vlax-for objPgSetup colPgSetups2
(setq sName (vlax-get-property objPgSetup 'Name))
(if (= sName psname)
(progn
;;add the page setup to the current doc
(setq objPgSetup2 (vla-add colPgSetups1 sName :vlax-false)) ;:vlax-true = Model tab only
(vla-CopyFrom objPgSetup2 objPgSetup)
)
) ;if
(vlax-release-object objPgSetup) ;release the page setup
) ;vlax-for
(vlax-release-object colPgSetups1)
(vlax-release-object colPgSetups2)
(vla-close doc2)
(vlax-release-object doc2)
) ;progn
) ;if
)
(defun DelPgSetups (/ colPgSetups objPgSetup)
(vl-load-com)
;;get the ACAD_PLOTSETTINGS dictionary
(setq colPgSetups (vla-get-PlotConfigurations *doc*))
;;get each page setup in the ACAD_PLOTSETTINGS dictionary
(vlax-for objPgSetup colPgSetups
(vla-delete objPgSetup) ;delete the page setup from the dictionary
(vlax-release-object objPgSetup) ;release the page setup
) ;vlax-for
(vlax-release-object colPgSetups)
(princ)
)
(defun C:TEST()
(ImpPgSetups "MyEPlotTest")
)
<< << <<
I hope this helps,
Wayne Brill
Autodesk Developer Network