Author Topic: Help needed...again (Print View Routine)  (Read 4867 times)

0 Members and 1 Guest are viewing this topic.

MvdP

  • Guest
Help needed...again (Print View Routine)
« on: April 07, 2008, 07:50:05 AM »
Help needed again with my print view routine.
I want to enhance this code to add an "how many copies" option. just like CAD's plottabs routine.
I looked to his plottabs code but i can't figure out how add this to my code.
First thing i want know if it is possible in my print view routine.
And the second one if it is possible how to do this.
(I added an edit box in dcl an some of cab's code in my lsp)


LSP Code
Code: [Select]
; Printview.lsp
  (defun QuanCtrl()
    (if (> (setq quantity (atoi (get_tile "quantity"))) 1)
     )
  )


(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_printview_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)

  (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 schaall (rtos(getvar "userr1")))
  (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 "quantity" "(QuanCtrl)")
(action_tile "fit" "(mode_tile \"printschaallijst\" (if (setq fitflag (= $value \"1\")) 1 0))")
(action_tile "cancel" "(setq viewselect \"\")(done_dialog)")
(action_tile "help" "(txtbox_printview_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

  (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)"))
)

     
     (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;;;;;;;;

DCL Code
Code: [Select]
printview : dialog {label = "Print Views";                                                     
: spacer { height = 1;}
: row {                                                                                           
    : boxed_column { label = "< Selecteer Views > ";                                                     
      : list_box { key = "viewbox";  width = 20; height = 20; multiple_select = true; }             
                                                                                                 

: row
           { : button { key = "selall"; label = "&Select All";}
             : button { key = "clrall"; label = "&Clear All";}
           } }


       : column {                                                                                     

: boxed_row { label = "< Selecteer Printer >";                                                         
: popup_list { key = "plotterlijst"; width = 30;}                                             
       }

: boxed_row { label = "< Selecteer Print Stijl >";                                                         
        : popup_list { key = "printstijlctb"; width = 30;}                                             
      }

: boxed_row { label = "< Selecteer Papier Formaat >";                                                         
: popup_list { key = "papierformaatlijst"; width = 30;}                                             
      }

: boxed_column { label = "< Selecteer schaal >";                                                         
: popup_list { key = "printschaallijst"; width = 30;}
: toggle { key = "fit";  label = "Fit to Paper";mnemonic = "F";}
      }
: boxed_column { label = "< Selecteer Aantal >";                                                         
: edit_box  { key = "quantity"; width = 30;edit_width = 2;edit_limit = 2; value = "1";}
      }
  }
  }

:boxed_row{
:text{label = " Huidige Schaal :";}
:text{key   = "schaall"       ;width = 5;}

:spacer { height = 2;}
}

  :spacer { height = 1;}
  ok_cancel_help ;                                                                                       
}

septicad

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #1 on: April 07, 2008, 08:43:07 AM »
to start: this code will not get the variable unless it is a called in the action_tile statement

Code: [Select]
  (defun QuanCtrl()
    (if (> (setq quantity (atoi (get_tile "quantity"))) 1)
     )
  )

to set the quantity variable add it to the action_tile statement of the "accept" button
Code: [Select]
  (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\"))
;;;;; add this line to extract the DCL tile info [i.e. # of copies]
     (setq quantity (atoi (get_tile \"quantity\")))
     (done_dialog)
    )"
    )

then use the (repeat quantity....plot function....end repeat)

MvdP

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #2 on: April 07, 2008, 09:32:01 AM »
Added and i got an error

Initializing...syntax error


septicad

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #3 on: April 07, 2008, 11:20:42 AM »


How about changing this:

 
Code: [Select]
(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)
    )"
    )
to this:

Code: [Select]
  (action_tile "accept" "(SaveVars)(done_dialog)")
and create a function to call when accept button is pressed. This eliminates all the confusing \'s

   
Code: [Select]
(defun saveVars ()
     (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"))
     (setq quantity (atoi (get_tile "quantity")))
    )

MvdP

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #4 on: April 07, 2008, 11:32:56 AM »
I am not behind a computer with autocad installed , i will try your code tomorrow.

septicad

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #5 on: April 07, 2008, 01:38:49 PM »
i couldn't actually try the code... can you post the DCL and LSP files as attachments... The functions loaded okay but i kept on getting an error when the function ran... wouldn't get past the defun statement....??? probably bad text file format...

if you post the files i will try to get it to work for you....

steve

MvdP

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #6 on: April 08, 2008, 02:20:12 AM »
First of all i appreciate your help.
I changed the code a bit (select quantity in popup_list  instead of typing in edit box)it is now without errors..Hope this is the right way in what i am trying to achieve.
So no quantity variable is set but when i select f.i. quantity 10 in popup_list and type this (princ quantity) on command line it says 9.
Now you mentioned i must add repeat.. plot quantity .. end repeat..,  but i can't figure out where to put this.?

Attached are the two files without the repeat part.
« Last Edit: April 08, 2008, 02:26:24 AM by MvdP »

MvdP

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #7 on: April 15, 2008, 03:23:21 AM »
Because there are no no replies does this mean that what i want is not possible.?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Help needed...again (Print View Routine)
« Reply #8 on: April 15, 2008, 08:04:08 AM »
No, it likely means that
  • nobody has had time to deal with it
  • the right person has not looked at it
  • both
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

septicad

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #9 on: April 15, 2008, 01:04:24 PM »
been skiing....since thursday  :-P    -  and yes no time anymore...its spring finally...

I tried to run the lsp in Bricscad v7v8 and I get

Quote
: printview

An error has occurred: null function

not too sure whats up with it... language... special characters?

daron

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #10 on: April 15, 2008, 02:08:52 PM »
Bricscad v7v8

ding, ding.

I have a friend who works with BCad V8. While they tout it as like autocad, I have the worst time trying to muddle my way through it and not all of the lisps that work in cad work in Bcad. You're going to have to step through the code yourself to get it to work, or hope that someone on here who uses BCad is able to help you.

MvdP

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #11 on: April 16, 2008, 01:48:15 AM »
The code contains no special characters but some of it is in dutch.
In AutoCAD 2009 this code is working except the quantity part.

septicad

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #12 on: April 16, 2008, 10:02:14 AM »
all programs have bugs..... i'll post it to bcad support and see what they say...

MvdP

  • Guest
Re: Help needed...again (Print View Routine)
« Reply #13 on: April 16, 2008, 11:35:39 AM »
Sorry for asking,
but how can BCad help me with getting this routine working in AutoCAD.?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help needed...again (Print View Routine)
« Reply #14 on: April 16, 2008, 04:56:29 PM »
I'm really short on time but I'll try and look at the routine tonight or tomorrow.
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.