Jump to content

Recommended Posts

Posted

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)
  )
Posted

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.

 

Posted

There's no addLayout function.

The problem you're having is with code defining addLayout you haven't posted.

Posted

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.

 

Posted

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.

  • Like 1
Posted

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

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...