Author Topic: Help needed adjusting my print view routine  (Read 2034 times)

0 Members and 1 Guest are viewing this topic.

MvdP

  • Guest
Help needed adjusting my print view routine
« on: September 19, 2007, 04:33:41 AM »
I need help in adjusting my print view routine.
There are 4 printers to choose from in this routine and each printer uses an different paper size name.
For example ISO A3 (297.00 x 420.00 MM) or A3
This is what i am trying to do with conditions.

But it Vlisp gives an error


; error: too few arguments in SETQ: (SETQ PPF = "ISO A4 (210.00 x 297.00 MM)")

What am i doing wrong.?

Code: [Select]
; Printview.lsp
(defun getnames (tablename / data result)
  (while (setq data (tblnext tablename (null data)))
    (setq result (cons (list (cdr (assoc 2 data))
                             (cdr (assoc 40 data))
                             (cdr (assoc 41 data))
                       ) ;_ end of LIST
                       result
                 ) ;_ end of CONS
    ) ;_ end of SETQ
  ) ;_ end of WHILE
) ;_ end of DEFUN

  ;;--------------------------------------------------------------------
  ;help message for dialog box.
  (defun txtbox_infohelp ()
    (alert
      (strcat
        "Deze routine print de geselecteerde views naar de standaard Printer.       \n\n"
        "Deze views worden geprint op de geselecteerde schaal en peninstellingen.\n"
        "Orientatie word automatisch geregeld.\n"
        "Werkt alleen om direct te printen en NIET naar bijv. plt files.\n"
        "Klik op OK om dit venster te sluiten.\n\n"
       )
    )
  )
  ;;--------------------------------------------------------------------

;Start routine
(defun c:printview (/           ocmd        ocmddia     oexpert
                    oosmode     viewlijst   dianummer   viewselect
                    papierformaat           teller      item
                    orientatie  viewnaam    hoogte      breedte
                   ) ;Save values of variables to change

;;(setvar "cmdecho" 0)

  (setq viewlijst ;Get list of views and sort it
         (vl-sort (getnames "view")
                  (function (lambda (a b) (< (nth 0 a) (nth 0 b))))
         ) ;_ end of VL-SORT
  ) ;_ end of SETQ
 
  (setq dianummer (load_dialog "printview.DCL")) ;Start dialog to select views
  (new_dialog "printview" dianummer)
  (setq teller 0)

(setq schaall (rtos(getvar "userr1")))
  (start_list "viewbox")
  (repeat (length viewlijst)
    (add_list (car (nth teller viewlijst)))
    (setq teller (+ 1 teller))
  ) ;_ end of REPEAT
  (end_list)

(setq printschaallijst(list  "1:1" "1:2" "1:5" "1:10" "1:20" "1:50" "1:100" "1:200" "1:500" "1:1000"))
(start_list "printschaallijst")
(mapcar 'add_list printschaallijst)
(end_list)

(setq plotterlijst (list
"Canon Kleuren Printer.pc3"    ; <- ppf="A4" / ppf="A3"
"HoofdPrinter.pc3"             ; <- ppf="A4" / ppf="A3"
"Laserjet A3 Noord.pc3"        ; <- ppf="ISO A4 (210.00 x 297.00 MM)" / ppf="ISO A3 (297.00 x 420.00 MM)"
"Laserjet A3 Zuid.pc3"         ; <- ppf="ISO A4 (210.00 x 297.00 MM)" / ppf="ISO A3 (297.00 x 420.00 MM)"
))
(start_list "plotterlijst")
(mapcar 'add_list plotterlijst)
(end_list)


(setq printstijlctb (list
"Plotter Dun.ctb"
"Plotter Middel.ctb"
"Plotter Normaal.ctb"))
(start_list "printstijlctb")
(mapcar 'add_list printstijlctb)
(end_list)

(setq papierformaatlijst (list
"A4"
"A3"
))

  (start_list "papierformaatlijst")
(mapcar 'add_list papierformaatlijst)
(end_list)
 
  (action_tile
    "accept"
    "(progn
     (setq viewselect (get_tile \"viewbox\"))
     (setq papierformaat (get_tile \"papierformaatlijst\"))
     (setq printschaal (get_tile \"printschaallijst\"))
     (setq printers (get_tile \"plotterlijst\"))
     (setq printctb (get_tile \"printstijlctb\"))
     (done_dialog)
    )"
    )

 
;;  ) ;_ end of ACTION_TILE


  ;;  CAB start


  (setq printer (nth (atoi printers) plotterlijst))
     (setq pf (nth (atoi papierformaat) papierformaatlijst))
     (cond
((and (= printer "HoofdPrinter.pc3")          (= pf "A3"))(setq ppf = "A3"))
((and (= printer "HoofdPrinter.pc3")          (= pf "A4"))(setq ppf = "A4"))
((and (= printer "Canon Kleuren Printer.pc3") (= pf "A3"))(setq ppf = "A3"))
((and (= printer "Canon Kleuren Printer.pc3") (= pf "A4"))(setq ppf = "A4"))
((and (= printer "Laserjet A3 Noord.pc3")     (= pf "A3"))(setq ppf = "ISO A3 (297.00 x 420.00 MM)"))
((and (= printer "Laserjet A3 Noord.pc3")     (= pf "A4"))(setq ppf = "ISO A4 (210.00 x 297.00 MM)"))
((and (= printer "Laserjet A3 Zuid.pc3")      (= pf "A3"))(setq ppf = "ISO A3 (297.00 x 420.00 MM)"))
((and (= printer "Laserjet A3 Zuid.pc3")      (= pf "A4"))(setq ppf = "ISO A4 (210.00 x 297.00 MM)"))
)
  (setq schaal (rtos(getvar "userr1")))
(setq dwgsch (strcat  "1:" schaal))
 
  (set_tile "viewbox" (if viewselect viewselect "")) ; default to none selected
  (action_tile "selall" "(select_all)")
  (action_tile "clrall" "(set_tile \"viewbox\" \"\")")
(defun select_all (/ sel cnt)
    (setq cnt 0
  sel ""
    )
    (repeat (length viewlijst)
      (setq sel (strcat sel (itoa cnt) " "))
      (setq cnt (1+ cnt))
    )
    (set_tile "viewbox" sel)
  )
  ;;  CAB end vl-list




(set_tile "plotterlijst" "1")
(set_tile "papierformaatlijst" "1")
(set_tile "printstijlctb" "2")
(set_tile "printschaallijst" "2")
(set_tile "schaall" dwgsch)
(action_tile "fit" "(mode_tile \"printschaallijst\" (if (setq fitflag (= $value \"1\")) 1 0))")
(action_tile "cancel" "(setq viewselect \"\")(done_dialog)")
(action_tile "help" "(txtbox_infohelp)")
  (start_dialog)
  (unload_dialog dianummer) ;If a view is selected, then print it
  (if (/= viewselect "")
    (progn
      (setq viewselect (read (strcat "(" viewselect ")"))) ;Convert string to list
           (setq teller 0)
           (repeat (length viewselect) ;Loop to process all selected views
             (setq item     (nth teller viewselect)
                   viewnaam (car (nth item viewlijst)) ; Name of view
                   hoogte   (cadr (nth item viewlijst)) ; Height of view
                   breedte  (car (cddr (nth item viewlijst))) ; Width of view
             ) ;_ end of SETQ
             (if (< breedte hoogte) ;Set paperorientation according to height/width
               (setq orientatie "Portrait")
               (setq orientatie "Landscape")
             ) ;_ end of IF
     (command "-plot" ; Print view
                      "yes" ;Detailed plot configuration? [Yes/No] <No>
                      "model" ;Enter a layout name or [?] <Model>
printer ;Enter an output device name
;(nth (atoi printers) plotterlijst) ;Enter an output device name
ppf ;Enter paper size:
;(nth (atoi papierformaat) papierformaatlijst);Enter paper size:
      "M" ;Inches/milimeters
                      orientatie ;Enter drawing orientation:
                      "n" ;Plot upside down:
                      "view" ;Enter plot area:
                      viewnaam ;Enter view name:
(if fitflag "Fit" (vl-string-translate ":" "=" (nth (atoi printschaal) printschaallijst))) ;Enter plot scale
                      "Center" ;Enter plot offset
                      "y" ;Plot with plot styles:
(nth (atoi printctb) printstijlctb) ;Enter plot style table name
                      "y" ;Plot with lineweights:
                      "n" ;Remove hidden lines
                      "n" ;Write the plot to a file [Yes/No] <N>:
                      "n" ;Save changes to model tab [Yes/No]? <N>
                      "y" ;Proceed with plot [Yes/No] <Y>:
             ) ;_ end of COMMAND

             (setq teller (+ 1 teller))
           ) ;_ end of REPEAT
    ) ;_ end of PROGN
  (princ "\nJe hebt geen views geselecteerd en er is dus ook niets geprint.....!")
  ) ;_ end of IF

  (princ)
) ;_ end of DEFUN
;|«Visual LISP© Format Options»
(72 2 1 2 T "end of " 60 9 1 1 0 T nil T T)
;*** DO NOT add text below the comment! ***|;
;;;; end routine;;;;;;;;
« Last Edit: September 19, 2007, 06:00:13 AM by Mark Thomas »

Crank

  • Water Moccasin
  • Posts: 1503
Re: Help needed adjusting my print view routine
« Reply #1 on: September 19, 2007, 07:20:38 AM »
Quote
((and (= printer "HoofdPrinter.pc3")          (= pf "A3"))(setq ppf = "A3"))
((and (= printer "HoofdPrinter.pc3")          (= pf "A4"))(setq ppf = "A4"))
((and (= printer "Canon Kleuren Printer.pc3") (= pf "A3"))(setq ppf = "A3"))
((and (= printer "Canon Kleuren Printer.pc3") (= pf "A4"))(setq ppf = "A4"))
((and (= printer "Laserjet A3 Noord.pc3")     (= pf "A3"))(setq ppf = "ISO A3 (297.00 x 420.00 MM)"))
((and (= printer "Laserjet A3 Noord.pc3")     (= pf "A4"))(setq ppf = "ISO A4 (210.00 x 297.00 MM)"))
((and (= printer "Laserjet A3 Zuid.pc3")      (= pf "A3"))(setq ppf = "ISO A3 (297.00 x 420.00 MM)"))
((and (= printer "Laserjet A3 Zuid.pc3")      (= pf "A4"))(setq ppf = "ISO A4 (210.00 x 297.00 MM)"))
Not tested your code, but you must remove =.
Vault Professional 2023     +     AEC Collection

MvdP

  • Guest
Re: Help needed adjusting my print view routine
« Reply #2 on: September 19, 2007, 08:44:10 AM »
Thanks Crank that did the trick..


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help needed adjusting my print view routine
« Reply #3 on: September 19, 2007, 09:19:10 AM »
And you can change to this:
Code: [Select]
     (cond
((= printer "HoofdPrinter.pc3") (setq ppf pf))
((= printer "Canon Kleuren Printer.pc3")(setq ppf pf))
((and (= printer "Laserjet A3 Noord.pc3")     (= pf "A3"))(setq ppf "ISO A3 (297.00 x 420.00 MM)"))
((and (= printer "Laserjet A3 Noord.pc3")     (= pf "A4"))(setq ppf "ISO A4 (210.00 x 297.00 MM)"))
((and (= printer "Laserjet A3 Zuid.pc3")      (= pf "A3"))(setq ppf "ISO A3 (297.00 x 420.00 MM)"))
((and (= printer "Laserjet A3 Zuid.pc3")      (= pf "A4"))(setq ppf "ISO A4 (210.00 x 297.00 MM)"))
)
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.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Help needed adjusting my print view routine
« Reply #4 on: September 19, 2007, 09:28:00 AM »
http://sourceforge.net/projects/opendcl

C'mon, all the cool kids are doin it . . .   :wink:
James Buzbee
Windows 8