Kowal Posted May 26, 2021 Posted May 26, 2021 Why is the new layout created with the default viewport? (vl-load-com) (defun c:addLay (/ name lcv) (setq lcv (getvar "LAYOUTCREATEVIEWPORT")) (setvar "LAYOUTCREATEVIEWPORT" 0) (setq name (getstring "\nLayout name: ")) (addLayout name) (setvar "LAYOUTCREATEVIEWPORT" lcv) (princ) ) Quote
mhupp Posted May 26, 2021 Posted May 26, 2021 What are you asking for? If you use the same layout with title block create the layout you want in a blank drawing. Save it as a template use the layout from template (vl-cmdf "_.Layout" "T" "template.dwt" "tabname") This is probably more what your looking for but needs a existing layout to copy from. Quote
tombu Posted May 26, 2021 Posted May 26, 2021 There's no addLayout function. The problem you're having is with code defining addLayout you haven't posted. Quote
Kowal Posted May 26, 2021 Author Posted May 26, 2021 It's all code. (defun addLayout (name / acadApp acadDoc layouts objLayout layouts) (setq acadApp (vlax-get-Acad-object)) (setq acadDoc (vla-get-ActiveDocument acadApp)) (setq layouts (vla-get-Layouts acadDoc)) (vlax-for objLayout layouts (if (= (vla-get-name objLayout) name) (progn (princ (strcat "\nDeleted Layout named " (vla-get-name objLayout) "...") ) (vla-delete objLayout) (vlax-release-object objLayout) );progn );if );vlax-for (setq layoutObj (vla-add layouts name)) (vla-put-StyleSheet layoutObj "Fill Patterns.ctb") (vla-put-configname layoutObj "DWG to PDF.pc3") (vla-put-PlotRotation layoutObj ac0degrees) (vla-put-canonicalmedianame layoutObj "ISO_full_bleed_A4_(210.00_x_297.00_MM)") ) ;================================================================================================== (vl-load-com) (defun c:addLay (/ name lcv) (setq lcv (getvar "LAYOUTCREATEVIEWPORT")) (setvar "LAYOUTCREATEVIEWPORT" 0) (setq name (getstring "\nLayout name: ")) (addLayout name) (setvar "LAYOUTCREATEVIEWPORT" lcv) (princ) ) First example: 1. Options -> Display -> Layout elements -> Create viewport in new layouts (ON) or (setvar "LAYOUTCREATEVIEWPORT" 1) 2. Runs lisp: addlay Creates a layout with the default viewport. Second example: 1. Options -> Display -> Layout elements -> Create viewport in new layouts (OFF) or (setvar "LAYOUTCREATEVIEWPORT" 0) 2. Runs lisp: addlay Creates a layout without the default viewport. Why does it work like that? The order of the lisp operations is this: 1. Retrieves the value of an AutoCAD system variable ("LAYOUTCREATEVIEWPORT") and set to variable. 2. Sets an AutoCAD system variable ("LAYOUTCREATEVIEWPORT") to 0. 3. Creat new layout. 4. Sets an AutoCAD system variable ("LAYOUTCREATEVIEWPORT") to variable value before run lisp. Quote
tombu Posted May 29, 2021 Posted May 29, 2021 I've always turned that Off every time I install a new version. Never understood the purpose of a random viewport on a layout that hasn't even had a size set. Might be an easy solution. I added a Drop-down in a custom CUI with macros to add layouts for various sizes & purposes previously set up in my default template file with title block, viewports, and page setups for both plotter and PDF using Lee Mac's Steal from Drawing lisp: http://lee-mac.com/steal.html ^C^C^P(Steal (strcat (vl-filename-directory (getenv "QnewTemplate")) (chr 92) "AutoCAD Template" (chr 92) "TemplateBlks.dwt") (list (list "Page Setups" (list "11×17" "11×17 PDF"))(list "Layouts" (list "11×17")))) You can import any layout from any drawing or template you've already set up the way you want and import text and dimension styles or linetypes at the same time if you wish. Simple and functional. 1 Quote
BIGAL Posted May 29, 2021 Posted May 29, 2021 Like tombu our surveyors have around 20 std title blocks that need to go in a layout so have a menu that allows them to pick correct one, inserts a external dwg which only has title block 1 Quote
Recommended Posts
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.