Author Topic: Lisp for creating layout... errors out because the layout is not yet created.. (  (Read 1776 times)

0 Members and 1 Guest are viewing this topic.

JOSHD0000

  • Guest
I have a lisp below that I want to use to create layout for plotting. It also deletes the layout if it already exists so a new updated layout is created. My problem is apparently AutoCAD does not run these commands mediately and when I try to switch to the new layout within the lisp the lisp error because the layout does not yet exist. Can anyone help me with this?
 :lol:

(DEFUN C:DFS ()
(COMMAND "ZOOM" "E")
(COMMAND "-LAYER" "A" "S" "ONE" "" "" "")
(COMMAND "LAYOUT" "D" "DFS Continental")
(COMMAND "LAYOUT" "T" "DFS Continental")
(setvar "CTAB" (strcat "DFS CONTINENTAL"))
(COMMAND "-LAYER" "F" "**" "")
(COMMAND "-LAYER" "T" "DATE" "")
(COMMAND "MS")
(COMMAND "COPY" "ALL" "" "0,0" "0,0")
(COMMAND "CHSPACE" "P" "")
(COMMAND "PS")
(COMMAND "-LAYER" "U" "**" "")
(COMMAND "-LAYER" "A" "R" "ONE" "" "")
(COMMAND "-LAYER" "A" "D" "ONE" "" "")
(COMMAND "VPLAYER" "F" "DATE" "ALL" "")
(COMMAND "REGEN")
(COMMAND "QSAVE")
(princ)
)
 
« Last Edit: February 02, 2007, 12:42:32 PM by JOSHD0000 »

Hangman

  • Swamp Rat
  • Posts: 566
Well, just off the top of my head, the first thing I see is the
(command "layout" "T" "DFS Continental")
You have not specified where the Template is at, nor have you specified the template itself.  I am assuming you are searching for the layout "DFS Continental".  It has to be in a template somewhere on your machine.
So you need something to the effect of:
(setq path-to-template (vl-file-directory-p somepath))
(setq template-name (get the template))  ; I can't think at the moment of how one would approach this.
(If (not (template-name))
  (ALERT user))

After the template has been found, and the layout DFS Continental has been pulled from it, the rest should fall together.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

terrycadd

  • Guest
Here is the only example I found in our AutoLISP code per (command "LAYOUT" "T" ...

(command "LAYOUT" "T" "L:\\DS\\Assy\\PF\\PlatForm.dwg" "Sheet1")