by Fenton Webb
Here’s a nice example that shows how to add a Layout using Visual LISP. It also shows how to set a Plot Style configuration and the Paper Size, and then make the new Layout active…
(defun c:addMyLayout ()
(vl–load–com)
(setq acadApp (vlax–get–Acad–object))
(setq acadDoc (vla–get–ActiveDocument acadApp))
(setq layouts (vla–get–Layouts acadDoc))
;; Delete the layout named "Test" if it exists
(vlax–for objLayout layouts
(if (= (vla–get–name objLayout) "Test")
(progn
(princ
(strcat "\nDeleted Layout named "
(vla–get–name objLayout) "…"
)
)
(vla–delete objLayout) ;delete the Layout
(vlax–release–object objLayout) ; release the Layout Object
);progn
);if
) ;vlax–for
(setq layoutObj (vla–add layouts "Test"))
;; Assign Grayscale.CTB to the Layout
(vla–put–StyleSheet layoutObj "Grayscale.ctb")
;; Assign DWF configuration to the Layout
(if (= (substr (vlax–variant–value (vla–getvariable acadDoc "ACADVER")) 1 2) "15")
(vla–put–configname layoutObj "PublishToWeb DWF.pc3")
(vla–put–configname layoutObj "DWF6 ePlot.pc3")
) ;if
;; Assign Paper Size B to the Layout
(vla–put–canonicalmedianame
layoutObj
"ANSI_expand_B_(11.00_x_17.00_Inches)"
)
;; Make the new Layout Active
(vla–put–activelayout acadDoc layoutObj)
;; Example getting StyleSheet and Configname, not doing anything
;; with them here however
(setq currPStyle (vla–Get–StyleSheet layoutObj))
(setq currConfig (vla–Get–configname layoutObj))
(princ)
)

Leave a Reply to SalamaCancel reply