How to invoke autolisp routine and script file to one common autolispfile.

Discussion in 'AutoCAD' started by maqlukas, Nov 25, 2009.

  1. maqlukas

    maqlukas Guest

    Hi all,
    Does anybody know how to build one autolisp routine which invokes both
    script command and load a lot of other autolisp subroutines in such
    way that then with one command I can run e.g. batch plot through many
    drawings without repeat (load "routine1") (routine1) (load "routine2")
    (routine2) and many subsidiary lisp files. Så far it does work but
    seems to be for me too clumsy.
    Here comes my present and working system:

    (defun C:pLOTIT ()
    ...
    (command "-plot" "Yes" (getvar "CTAB") "DWG To PDF.pc3" "ISO A1
    (594.00 x 841.00 MM)" "M" "L" "Y" "E" "1:1" "Center" "Y"
    "monochrome.ctb" "Y" "N" "N" "N" plotname "Y" "Y")
    ...
    )


    (defun C:MAKEPLOT ( )
    ;;; creates scriptfile
    (open "scriptfile" "w")
    (write-line "(load \"C:\\\\PLOTIT.lsp\")" "scriptfile")
    (write-line "PLOTIT" "scriptfile")
    ...
    ...
    (close "scriptfile")

    ;;; runs scriptfile
    (command "script" "scriptfile")

    )

    When I load and run MAKEPLOT it works perfectly!

    Now, what I want to avoid is repeating (write-line "(load \"C:\\\
    \PLOTIT.lsp\")" "scriptfile") in my scriptfile and move the PLOTIT
    subroutine into the host file MAKEPLOT, like this:
    (defun C:MAKEPLOT ( )

    (defun PLOTIT ()
    ...
    (command "-plot" "Yes" (getvar "CTAB") "DWG To PDF.pc3" "ISO A1
    (594.00 x 841.00 MM)" "M" "L" "Y" "E" "1:1" "Center" "Y"
    "monochrome.ctb" "Y" "N" "N" "N" plotname "Y" "Y")
    ...
    )

    ;;; creates scriptfile
    (open "scriptfile" "w")
    ;;; (write-line "(load \"C:\\\\PLOTIT.lsp\")" "scriptfile")
    (write-line "PLOTIT" "scriptfile")
    ...
    ...
    (close "scriptfile")

    ;;; runs scriptfile
    (command "script" "scriptfile")

    )
    It works but only on the first drawing and after this stops with the
    meassge 'PLOTIT' unkown command.

    Any idea how to workaround the problem?

    Regards
    Maq
     
    maqlukas, Nov 25, 2009
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.