Author Topic: Help with Print Views Routine...  (Read 10796 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help with Print Views Routine...
« Reply #45 on: April 11, 2006, 08:46:44 AM »
When you reference a tile key the string must match EXACTLY. So in the lisp the "FIT" must be all caps.
Or change the DCL key to "fit".

The way I handles the collate was to send each sheet to the plot command then start again sending
until I got the number of copies needed. Take a look at the PlotTabs.lsp for more info.
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.

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #46 on: April 11, 2006, 09:46:47 AM »
CAB Thanks
When you reference a tile key the string must match EXACTLY. So in the lisp the "FIT" must be all caps.
Or change the DCL key to "fit".

That did the trick.

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #47 on: June 06, 2006, 05:31:04 AM »
Is it possible to show f.i 1:5 (looks better in list) in my dcl  but uses 1=5.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help with Print Views Routine...
« Reply #48 on: June 06, 2006, 07:25:38 AM »
Use this:
(setq printschaallijst (list "1:1" "1:2" "1:5" "1:10" "1:20" "1:50" "1:100" "1:200" "1:500" "1:1000"))
(setq printschaallijst_2 (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)

With this:
(nth (atoi printschaal) printschaallijst_2) ;Enter plot scale


Or this:
(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)

With this:
(vl-string-translate ":" "=" (nth (atoi printschaal) printschaallijst)) ;Enter plot scale
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.

CADaver

  • Guest
Re: Help with Print Views Routine...
« Reply #49 on: June 06, 2006, 07:57:55 AM »
Could you post the final code when you're done?  I'd like to wade through this one.

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #50 on: June 06, 2006, 08:19:37 AM »
Thanks CAB it is working great.
« Last Edit: June 07, 2006, 06:14:01 AM by MvdP »

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #51 on: June 07, 2006, 06:14:43 AM »
How can i set my print scale to fit when i select the fit toggle button.?Or can't it be done because of this line

Code: [Select]
(vl-string-translate ":" "=" (nth (atoi printschaal) printschaallijst)) ;Enter plot scale


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


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


    : column {                                                                                     
      : radio_column { label = "< Selecteer Papier Formaat > "; key = "papierformaat";                           
        : radio_button { label = "A4 210x297 mm"; key = "ISO A4 (210.00 x 297.00 MM)";}             
        : radio_button { label = "A3 297x420 mm"; key = "ISO A3 (297.00 x 420.00 MM)"; value = "1";}
      }                                                                                             


: spacer { height = 1;}
      : boxed_row { label = "< Selecteer Printer >";                                                         
        : popup_list { key = "printers"; width = 30;}                                             
      }

      : boxed_column { label = "< Selecteer schaal >";                                                         
        : popup_list { key = "printschaallijst"; width = 30;}
        : toggle { key = "fit";  label = "Fit to Paper";}
      }

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

LSP
Code: [Select]
(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"
        "Please report any problems you may have.\n\n"
       )
    )
  )
  ;;--------------------------------------------------------------------



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

(setvar "cmdecho" 0)


  (init_vars1)
  (make_device_list)
  (init_vars2)
  (make_plotstyle_list)

  (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 "printviews.DCL")) ;Start dialog to select views
  (new_dialog "printviews" 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)


;;;--- Sort the plotstylelist
  (setq printstijl (acad_strlsort plotstyle-list))
  ;;;--- Add the list to the dialog box
  (start_list "printstijlctb" )
  (mapcar 'add_list plotstyle-list)
  (end_list)

;;;--- Sort the plotterlist
  (setq printer (acad_strlsort device-list))
  ;;;--- Add the list to the dialog box
  (start_list "printers" )
  (mapcar 'add_list device-list)
  (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)

  (action_tile
    "accept"
    "(progn
     (setq viewselect (get_tile \"viewbox\"))
     (setq papierformaat (get_tile \"papierformaat\"))
     (setq printschaal (get_tile \"printschaallijst\"))
     (setq printers (get_tile \"printers\"))
     (setq printctb (get_tile \"printstijlctb\"))
    (done_dialog)
    )"
  )

 
;;  ) ;_ end of ACTION_TILE


  ;;  CAB start
  (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 "printers" "6")
(set_tile "printstijlctb" "11")
(set_tile "printschaallijst" "2")
   
(action_tile "fit" "(mode_tile \"printschaallijst\" (if (= $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>
(nth (atoi printers) device-list) ;Enter an output device name
papierformaat ;Enter paper size:
                      "M" ;Inches/milimeters
                      orientatie ;Enter drawing orientation:
                      "n" ;Plot upside down:
                      "view" ;Enter plot area:
                      viewnaam ;Enter view name:
(vl-string-translate ":" "=" (nth (atoi printschaal) printschaallijst)) ;Enter plot scale
                      "Center" ;Enter plot offset
                      "y" ;Plot with plot styles:
(nth (atoi printctb) plotstyle-list) ;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.....!") ; Display text if no view or cancel is selected
  ) ;_ 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;;;;;;;;

;;===============================================
(defun make_device_list (/ curdwg pslayout)
  (setq curdwg (vla-get-ActiveDocument (vlax-get-Acad-Object))
    pslayout (vla-get-Layout (vla-get-PaperSpace curdwg))
  )
  (vla-RefreshPlotDeviceInfo pslayout)
  (vlax-safearray->list (vlax-variant-value (vla-GetPlotDeviceNames pslayout)))
) ; End make_device_list


(defun make_plotstyle_list (/ curdwg pslayout)
  (setq curdwg (vla-get-ActiveDocument (vlax-get-Acad-Object))
    pslayout (vla-get-Layout (vla-get-PaperSpace curdwg))
  )
  (vla-RefreshPlotDeviceInfo pslayout)
  (vlax-safearray->list (vlax-variant-value (vla-GetPlotStyleTableNames pslayout)))
) ; End make_plotstyle_list

;;===============================================
  (defun init_vars1 ()
    (if (not PLOTALL-DEVICE) (setq PLOTALL-DEVICE "None"))
         (setq  device-list (make_device_list))
          (if (and PLOTALL-DEVICE (member PLOTALL-DEVICE device-list))
      (setq device# (- (length device-list) (length (member PLOTALL-DEVICE device-list)))
      )
      (setq device# 0)
    )
  ) ; End init_vars1

  (defun init_vars2 ()
    (if (not PLOTSTYLE-DEVICE)(setq PLOTSTYLE-DEVICE "None"))
         (setq  plotstyle-list (make_plotstyle_list))
          (if (and PLOTSTYLE-DEVICE (member PLOTSTYLE-DEVICE plotstyle-list))
      (setq plotctb# (- (length plotstyle-list) (length (member PLOTSTYLE-DEVICE plotstyle-list)))
      )
      (setq plotctb# 0)
    )
  ) ; End init_vars2

;;===============================================


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help with Print Views Routine...
« Reply #52 on: June 07, 2006, 08:41:22 AM »
Try something like this:

Code: [Select]
(action_tile "fit" "(mode_tile \"printschaallijst\" (if (setq fitflag (= $value \"1\")) 1 0))")

Code: [Select]
                      (if fitflag
                        "Fit"
(vl-string-translate ":" "=" (nth (atoi printschaal) printschaallijst)) ;Enter plot scale
                        )
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help with Print Views Routine...
« Reply #53 on: June 07, 2006, 08:42:59 AM »
You may want to explore this routine. :-)
http://www.theswamp.org/index.php?topic=1916.0
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.

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #54 on: June 07, 2006, 09:11:47 AM »
CAB thanks again it works. And i definitely will take look at your code.