Author Topic: Broken plot lisp  (Read 3307 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
Broken plot lisp
« on: May 18, 2006, 07:47:32 AM »
Why does this work some of the time and not others?

Code: [Select]
;;;
;;; TITLE:@file.lsp
;;;
;;; Copyright (C) 2006 by Andy Hudson
;;;
;;; Permission to use, copy, modify, and distribute this
;;; software and its documentation for any purpose and without
;;; fee is hereby granted
;;;
;;; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR
;;; IMPLIED WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY
;;; PARTICULAR PURPOSE AND OF MERCHANTABILITY ARE HEREBY
;;; DISCLAIMED.
;;;
;;; Andy Hudson
;;; May 2006
;;;
;;;-------------------------------------------------------------
;;; Description:
;;;
;;; Plot routine to set up and plot to file
;;;
;;;-------------------------------------------------------------
;;; COMMAND - Various
;;;-------------------------------------------------------------
(defun c:@file ()
  (setq @tmode (getvar "tilemode"))
  (setq @cmd (getvar "cmdecho"))
  (setvar "cmdecho" 0)
;;filename
  (setq @fname1 (getvar "dwgname")
@fname2 (vl-string-right-trim ".dwg" @fname1)
@fname2 (vl-string-right-trim ".DWG" @fname1)
@fname3 (getvar "dwgprefix")
@fname (strcat @fname3 @fname2))
;;GET TITLE BLOCK NAME
    (setq @ss (entget (ssname (ssget "x" (list (cons 0 "insert") (cons 2 "*sheet"))) 0)))
  (setq @ss2 (CDR (assoc 2 @ss)))
;;; IF A1 TITLE SHEET FOUND
  (if (or (= @ss2 "A1_Sheet") (= @ss2 "A1_SHEET"))
    (setq @paper "ISO A1 - 594 x 841 mm. (landscape)"
  @PLOTTER "\\\\GLASGOW\\HP_PLOTTER"))
;;; IF A0 TITLE SHEET FOUND
  (if (or (= @ss2 "A0") (= @ss2 "A0"))
    (setq @paper "ISO A0 - 841 x 1189 mm."
  @PLOTTER "\\\\GLASGOW\\HP_PLOTTER"))
;;; PAGESETUP PART
  (PROGN
    (SETVAR "TILEMODE" 0)
    (command "-plot"
     "Y"
     ""
     @PLOTTER
     @paper
     "m"
     "LANDSCAPE"
     "NO"
     "EXTENTS"
     "1:1"
     "CENTER"
     "YES"
     "rybka battle - STANDARD.ctb"
     "YES"
     "NO"
     "NO"
     "NO"
     "YES"
     @FNAME
     "NO"
     "YES"
     ))
;;reset variables
    (setvar "cmdecho" @cmd)
  (princ)
  )

When it fails it always fails at the same point,
Code: [Select]
Command: @file
Unknown command "M".  Press F1 for help.
Unknown command "LANDSCAPE".  Press F1 for help.
Unknown command "NO".  Press F1 for help.
Unknown command "EXTENTS".  Press F1 for help.
Unknown command "1:1".  Press F1 for help.
Unknown command "CENTER".  Press F1 for help.
Unknown command "YES".  Press F1 for help.
Unknown command "RYBKA BATTLE - STANDARD.CTB".  Press F1 for help.
Unknown command "YES".  Press F1 for help.
Unknown command "NO".  Press F1 for help.
Unknown command "NO".  Press F1 for help.
Unknown command "NO".  Press F1 for help.
Unknown command "YES".  Press F1 for help.
Unknown command "R:\DWG\04\GLASGOW\504-011-00 NORTH LANARKSHIRE SCHOOLS\B21
CAMBUSNETHAN\ELEC\CURRENT\MODS\B21-PD-L-60-0-001-B".  Press F1 for help.
Unknown command "NO".  Press F1 for help.
Unknown command "YES".  Press F1 for help.

Anyone have any idea?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Chuck Gabriel

  • Guest
Re: Broken plot lisp
« Reply #1 on: May 18, 2006, 07:51:24 AM »
If you leave cmdecho on, the output will give you better hints as to what is causing the failure.

hudster

  • Gator
  • Posts: 2848
Re: Broken plot lisp
« Reply #2 on: May 18, 2006, 07:58:07 AM »
duh, i'm such an idiot at time :ugly:

When i comented out the cmdecho it was failing at the paper selection, i changed the layout and it worked.

Cheers Chuck
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Sdoman

  • Guest
Re: Broken plot lisp
« Reply #3 on: May 18, 2006, 08:04:29 AM »
When you see the error message "Unknown command" during a call to the Command function, it usually (always?) means that the preceding argument(s) caused the error.  Hence check the values of @PLOTTER and @paper.  Do they contain valid values at runtime?

What happens if the routine doesn't find the title block, or layouts "A0" or "A1" ?

hudster

  • Gator
  • Posts: 2848
Re: Broken plot lisp
« Reply #4 on: May 18, 2006, 08:56:29 AM »
It will, all our layouts have a drawing sheet, they are added automatically.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Broken plot lisp
« Reply #5 on: May 18, 2006, 09:22:28 AM »
Maybe something like this?

Code: [Select]
(defun c:@file (/ @cmd @fname @fname1 @fname2 @fname3 @paper @plotter @ss @ss2 @tmode)
  (setq @tmode (getvar "tilemode"))
  (setq @cmd (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  ;;filename
  (setq @fname (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname"))))
  ;;GET TITLE BLOCK NAME
  (setq @ss (entget (ssname (ssget "x" (list (cons 0 "insert") (cons 2 "*sheet"))) 0)))
  (setq @ss2 (cdr (assoc 2 @ss)))
  ;; IF TITLE SHEET FOUND
  (cond
    ((= (strcase @ss2) "A1_SHEET")
     (setq @paper   "ISO A1 - 594 x 841 mm. (landscape)"
           @plotter "\\\\GLASGOW\\HP_PLOTTER"
     )
    )
    ;; IF A0 TITLE SHEET FOUND
    ((= (strcase @ss2) "A0")
     (setq @paper   "ISO A0 - 841 x 1189 mm."
           @plotter "\\\\GLASGOW\\HP_PLOTTER"
     )
    )
  )
  ;; PAGESETUP PART
  (if @paper
    (progn
      (setvar "TILEMODE" 0)
      (command "-plot" "Y" "" @plotter @paper "m" "LANDSCAPE" "NO" "EXTENTS" "1:1" "CENTER" "YES"
               "rybka battle - STANDARD.ctb" "YES" "NO" "NO" "NO" "YES" @fname "NO" "YES"
              )
    )
    (alert "No Title Sheet Found")
  )
  ;;reset variables
  (setvar "cmdecho" @cmd)
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Sdoman

  • Guest
Re: Broken plot lisp
« Reply #6 on: May 18, 2006, 09:58:37 AM »

Maybe something like this?


Yes!  A little error checking goes a long way.  :-)

hudster

  • Gator
  • Posts: 2848
Re: Broken plot lisp
« Reply #7 on: May 18, 2006, 10:02:59 AM »
Cab you are the man. My code looks dreadful compared to yours :-(
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Broken plot lisp
« Reply #8 on: May 18, 2006, 10:15:25 AM »
You're welcome.

Keep writings code, you'll get there. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.