Set a page setup current with lsp

Set a page setup current with lsp

cslatteryAXGRE
Advocate Advocate
2,200 Views
3 Replies
Message 1 of 4

Set a page setup current with lsp

cslatteryAXGRE
Advocate
Advocate

I see this is talked about quite a bit. But I would like to be able to apply a page setup to the active layout tab with lsp. I have this for importing the page setup that I want, but I cannot seems to get it to be applied to my current layout without opening the page setup manager dialog box.

 

(defun C:3624PageSetup ()
(command "._-PSETUPIN" "X:/XX/Page Setups.dwg" "3624 PDF")
)

0 Likes
2,201 Views
3 Replies
Replies (3)
Message 2 of 4

LDShaw
Collaborator
Collaborator

Try this.

 

(defun C:3624PageSetup ()
(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))
)))

 

Help page 

 



0 Likes
Message 3 of 4

Baker_ADG
Advocate
Advocate
(defun C:22x34 ()
(vl-load-com) 

;(DelPgSetups) 

(setq pl (vla-get-PlotConfigurations
(vla-get-activedocument
(vlax-get-acad-object))))
(vlax-for item pl
(vlax-invoke-method item 'delete)
)
(command "._-PSETUPIN" "c:/path to dwg-dwt/drawing.dwt" "34x22 PDF")
(defun SetCurrentPageSetup (doc pcname / layout PlotConfig)
  (setq	doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq layout (vla-get-activelayout doc))
  (setq PlotConfig (vl-catch-all-apply
		     'vla-item
		     (list
		       (vla-get-PlotConfigurations
			 doc
		       )
		       pcname
		     )
		   )
  )
  (if (not (vl-catch-all-error-p PlotConfig))
    (vla-copyfrom layout PlotConfig)
  )
)

(SetCurrentPageSetup <AcadDocument> <PageSetupName>)
(SetCurrentPageSetup (vla-get-activedocument (vlax-get-acad-object)) "34x22 PDF")

;==

  (setq	aDoc  (vla-get-activedocument (vlax-get-acad-object))
	Layts (vla-get-layouts aDoc)
	clyt  (vla-get-activelayout aDoc)
  )
  (foreach
	    itm
	       (vl-remove (vla-get-name clyt) (layoutlist))
    (vla-copyfrom (vla-item Layts itm) clyt)
  )
)

this is what i used in the past. 

Jon Baker | Land Development & Infrastructure Design Manager
Alignment Design Group | Denver | Colorado
Civil 3D 2025 | Windows 11
0 Likes
Message 4 of 4

LDShaw
Collaborator
Collaborator

Just for fun if it does not find the setup it will tell you what page setups are in the dwg.

 

 

(defun C:3624PageSetup ()
(command "._-PSETUPIN" "x:\\xx\\trash1.dwg" "3624 PDF")

(defun lm:psetup2tab (/ d found setup-list)
(setq found nil) ; Initialize a variable to track if the page setup is found
(setq setup-list "") ; Initialize a string to collect page setup names

(vlax-for x (vla-get-plotconfigurations
(setq d (vla-get-activedocument (vlax-get-acad-object))))
(setq setup-list (strcat setup-list (vla-get-name x) "\n")) ; Append each page setup name to setup-list
(if (= (strcase "3624 PDF") (strcase (vla-get-name x)))
(progn
(setq found T) ; Set found to true if the page setup is found
(vl-catch-all-apply 'vla-copyfrom (list (vla-get-activelayout d) x))
)
)
)

(if (not found) ; If the page setup is not found, display an alert
(alert (strcat "The page setup '3624 PDF' was not found.\nAvailable page setups:\n" setup-list))
)
)

(lm:psetup2tab)
)

 

 

0 Likes