Jump to content

Problems with LISP For Plot


AQucsaiJr

Recommended Posts

I am trying to make a one step procedure for a common plot used in my office. I created a basic LISP to perform the task so that anyone in the office could use it and get the same results. My problem is I keep getting an error message that tells me the output device I want to use cannot be found. Could someone take a look at my LISP and see if there is something I am doing wrong? This LISP works in AutoCAD 2010 but I get this error when working in AutoCAD 2009. Most of the users in the office are on 2009.

CANON_ARCH-D_FLW - example.lsp

Link to comment
Share on other sites

Should have posted the LISP this way for easy reading...

 

;;Purpose: This command will auto-plot an ARCH-D size print to the canon plotter with a user specified plot scale

(DEFUN C:Archd (/ scale )
   (setq scale (getstring "Enter Plot Scale: "))
(command "-plotstamp" "off" "")
(COMMAND "-PLOT" "YES" "model" "\\PGEFS01\\WORKGROUP\\AUTOCAD\\PLOT FILES\\CANON IPF600 ARCH-D.PC3" "" "INCHES" "LANDSCAPE" "NO" "EXTENTS" scale "CENTER" "YES" "FP-Lineweights.CTB" "YES" "AS DISPLAYED" "NO" "NO" "YES")
(PRINC)
)

Link to comment
Share on other sites

Is plotstamp in 2009 can not remember if not you can do a version check "acadver" last number is what you want 2011=18.1 and not run

 

(if ((lambda (vrsn)
       (cond
        ((vl-string-search "R17.2" vrsn) (setq appstr "6.0")) ;09
        ((vl-string-search "R18.0" vrsn) (setq appstr "7.0")) ;10
        ((vl-string-search "R18.1" vrsn) (setq appstr "8.0")) ;11
        ((vl-string-search "R18.2" vrsn) (setq appstr "9.0")) ;12 ?
       ((alert "This version of C3D not supported!"))
       )
      )
      (vlax-product-key)
     )                         ; end if condition progn is true

Link to comment
Share on other sites

Yes, plotstamp is supported in 2009. The part of the LISP 2009 gets hung up on is finding the output device. I want it to locate a (.pc3) file that I have already set up on the server, which all users have access to. However this is not working for me. It works perfectly fine in 2010 but can not be located in 2009.

Link to comment
Share on other sites

This is what I use and it works across the office:

 

;Based on PageSetups from Alan J. Thompson
(defun c:A1 ()
(PlotReactorOFF)
 (if (findfile "T:/Drawing Tools/Templates/CCC2009.dwt")
   (progn
     (command "_.psetupin" (findfile "T:/Drawing Tools/Templates/CCC2009.dwt") "A1")
     (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
       (command "_yes")
     ) ;_ while
     T
   ) ;_ progn
 ) ;_ if
(command "-plot" "n" "" "A1" "" "n" "y" "n")
(command "_-purge" "a" "*" "N")
(setq CCC_Sheet "A1")
(command "updatefield" "all" "")
(command "regenall")
(command "_zoom" "e")
 (initdia)
 (command "._plot")
(PlotReactorON)
;(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun PlotReactorON nil
 (vl-load-com)
 ;; © Lee Mac 2010

 (  (lambda ( data foo / react )
      (if (setq react
            (vl-some
              (function
                (lambda ( reactor )
                  (if (eq data (vlr-data reactor)) reactor)
                )
              )
              (cdar
                (vlr-reactors :vlr-command-reactor)
              )
            )
          )
        (if (not (vlr-added-p react))
          (vlr-add react)
        )
        (setq react
          (vlr-command-reactor data
            (list
              (cons :vlr-commandwillstart foo)
            )
          )
        )
      )
      (if (vlr-added-p react)
        (princ "\n** Reactor Activated **")
        (princ "\n** Reactor Failed to Activate **")
      )
      react
    )
   "Plot-Reactor"
   'Plot-Callback
 )

 (princ)
)

(defun PlotReactorOFF nil
 (vl-load-com)
 ;; © Lee Mac 2010

 (  (lambda ( data foo / react )
      (if (setq react
            (vl-some
              (function
                (lambda ( reactor )
                  (if (eq data (vlr-data reactor)) reactor)
                )
              )
              (cdar
                (vlr-reactors :vlr-command-reactor)
              )
            )
          )
        (if (vlr-added-p react)
          (vlr-remove react)
        )
      )
      (if (or (not react) (not (vlr-added-p react)))
        (princ "\n** Reactor Deactivated **")
        (princ "\n** Reactor Failed to Deactivate **")
      )
      react
    )
   "Plot-Reactor"
   'Plot-Callback
 )
 
 (princ)
)

(defun Plot-Callback ( reactor arguments )
 (vl-load-com)

 (if (eq (strcase (car arguments)) "PLOT")
   (LM:Popup "Warning" 64 "Gotcha!!!   Please use the NNRDO Plot tools when plotting standard layouts!!")
 )

 (princ)
)

(defun LM:Popup ( title flags msg / WSHShell result )
 ;; © Lee Mac 2010
 (setq WSHShell (vlax-create-object "WScript.Shell"))
 (setq result   (vlax-invoke WSHShell 'Popup msg 0 title flags))
 (vlax-release-object WSHShell)
 
 result
)

Link to comment
Share on other sites

@woodman - I have not been able to get your LISP to work for what I need. Thank you for the LISP though. I will continue to work on it.

 

I have figured out how to get 2009 to recognize the output device but now I have another problem. I don't know how to get the paper size to change to what I want.

(DEFUN C:Archc (/ scale )
   (setq scale (getstring "Enter Plot Scale: "))
   (setq name (findfile "w:/AUTOCAD/PLOT FILES/CANON IPF600 ARCH-c.PC3"))
(command "-plotstamp" "off" "")
(COMMAND "-PLOT" "YES" "model" NAME "[i][color=black]Paper Size[/color][/i]" "INCHES" "LANDSCAPE" "NO" "EXTENTS" scale "CENTER" "YES" "FP-Lineweights.CTB" "YES" "AS DISPLAYED" "NO" "NO" "YES")
(PRINC)
)

The output I need is "ARCH C (18"x24")" however I can not figure out a way to get that to work because of the Parentheses in the name. Anyone know of a way I can do this? Maybe a setq variable or something of that nature??

Link to comment
Share on other sites

The problem is not the parentheses, but rather the extra apostrophes in the string, you will need to prefix these with a backslash escape character to mark them as literals.

 

"ARCH C (18\"x24\")"

 

You can realise the correct syntax when using code editors which offer syntax highlighting such as the Visual LISP IDE, Notepad++, etc.

Link to comment
Share on other sites

I don't set the paper size in the lisp. I have created page setups and call them from the lisp. They are stored in the template drawing. I have 1 template size for A1 and A3 and when the user calls either A1 or A3 plot the lisp loads a different page setup. I have done the same for pdf's as well.

 

For us it works very well.

Link to comment
Share on other sites

I have never tried to use a template file to do the settings for a print before. I will have to look into that.

 

Thanks for the information.

Link to comment
Share on other sites

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...