TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MvdP on March 16, 2006, 02:18:54 AM

Title: Help with Print Views Routine...
Post by: MvdP on March 16, 2006, 02:18:54 AM
I got this routine working but with radio buttons for selection of scale and plotstyle.But i want to make the selection in a drop down list.This is my attempt but i can t'get it to work.Help would be appreciated.

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


;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
  (setq ocmd    (getvar "cmdecho")
        ocmddia (getvar "cmddia")
        oexpert (getvar "expert")
        oosmode (getvar "osmode")
  ) ;_ end of SETQ
(command "cmdecho" 0 "cmddia" 1 "expert" 5 "osmode" 0) ;Change variables
  (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


  (init_vars1)
  (make_device_list)
  (init_vars2)
  (make_plotstyle_list)
;;  (init_vars3)
;;  (make_papersize_list)




  (setq dianummer (load_dialog "printview")) ;Start dialog to select views
  (new_dialog "printview" dianummer)
  (start_list "viewbox")
  (setq teller 0)
  (repeat (length viewlijst)
    (add_list (car (nth teller viewlijst)))
    (setq teller (+ 1 teller))
  ) ;_ end of REPEAT
  (end_list)
  (action_tile
    "accept"
    "(setq viewselect (get_tile \"viewbox\"))
(setq papierformaat (get_tile \"papierformaat\"))
(setq printschaal (get_tile \"printschaal\"))
;;;(setq printstijl (get_tile \"printstijl\"))
(action_tile "printstijl" "(setq printstijl (nth (atoi $value) displistprintstijl))"  ) 
(done_dialog)"
  ) ;_ end of ACTION_TILE
  (action_tile "cancel" "(setq viewselect \"\")(done_dialog)")
  (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
;;;For debug purpose
;;;          (princ (strcat "\nViewnummer: "
;;;                         (itoa item)
;;;                         "    Viewnaam: "
;;;                         viewnaam
;;;                         " Breedte: "
;;;                         (itoa (fix breedte))
;;;                         " Hoogte: "
;;;                         (itoa (fix hoogte))
;;;                 ) ;_ end of STRCAT
;;;          ) ;_ end of PRINC
;;;          (princ (strcat "\nPapierformaat: "
;;;                         papierformaat
;;;                         "    Papier orientatie: "
;;;                         orientatie
;;;                         "\n"
;;;                        ) ;_ end of strcat
;;;          ) ;_ end of PRINC
             (command "-plot" ; Print view
                      "yes" ;Detailed plot configuration? [Yes/No] <No>
                      "model" ;Enter a layout name or [?] <Model>
                      "Laserjet A3.pc3" ;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:
        printschaal ;Enter plot scale
;(strcat "1=" (itoa schl)) ;Enter plot scale
;"1=5"
                      "Center" ;Enter plot offset
                      "y" ;Plot with plot styles:
                      printstijl ;Enter plot style table name
;" Plotter Normaal.ctb" ;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 "\nGeen views gekozen.....!") ; Display text if no view or cancel is selected
  ) ;_ end of IF
  (command "cmddia" ocmddia "expert" oexpert "osmode" oosmode "cmdecho" ; Reset variables
           ocmd) ;_ end of command
  (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 make_papersize_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-GetCanonicalMediaNames 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

  (defun init_vars3 ()
    (if (not PLOTSIZE-DEVICE)(setq PLOTSIZE-DEVICE "None"))
         (setq  plotsize-list (make_papersize_list))
          (if (and PLOTSIZE-DEVICE (member PLOTSIZE-DEVICE plotsize-list))
      (setq plotsize# (- (length plotsize-list) (length (member PLOTSTYLE-DEVICE plotsize-list)))
      )
      (setq plotsize# 0)
    )
  ) ; End init_vars3

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



Code: [Select]
printview : dialog {label = "Print Views 2006";
: row {
: boxed_column {
        label = "Selecteer Views";
        : list_box {
//              fixed_width_font = true;
                key = "viewbox";
                width = 25;
                height = 20;
                multiple_select = true;
        }

} // End column
: spacer_1 {}
: column {
        fixed_height = true;
        alignment = top;
        : boxed_row {
                label = "Papier Formaat";
                : radio_column {   
                        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";
                        }
                } // End radiocolumn
        } // End row

: column {
        : boxed_row {
                label = "Print Schaal";
                : radio_column {   
                        key = "printschaal";     
                        : radio_button {
                                label = "1:1";
                                key = "1=1"; }
                        : radio_button {
                                label = "1:2";
                                key = "1=2"; }
: radio_button {
                                label = "1:5";
                                key = "1=5";
                                value = "1";} 
                        : radio_button {
                                label = "1:10";
                                key = "1=10"; } 
                        : radio_button {
                                label = "1:20";
                                key = "1=20"; }
}
}


: column {
        : boxed_row {
                label = "Print Stijl";
: popup_list {   
key = "printstijl";
is_enabled=false;
width = 30;   
                       
}
}
}
}
} // End column
} // End row
: spacer_1 {}
   ok_cancel ;
} // End dialog



Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 16, 2006, 11:42:50 AM
I tried to run your routine, and I got and error.  Can you supply a drawing, even with nothing in it but one that is yours that you would print, to test it on?
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 16, 2006, 12:13:53 PM
I am getting an error too.The dcl shows for one sec...and that's it.Any drawing with views must work.
Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 16, 2006, 12:30:04 PM
I had to revise this section of your code just to see the dialog box.
Code: [Select]
  (setq teller 0)
  (start_list "viewbox")
  (repeat (length viewlijst)
    (add_list (car (nth teller viewlijst)))
    (setq teller (+ 1 teller))
  ) ;_ end of REPEAT
  (end_list)
  (action_tile
    "accept"
    "(progn
     (setq viewselect (get_tile \"viewbox\"))
     (setq papierformaat (get_tile \"papierformaat\"))
     (setq printschaal (get_tile \"printschaal\"))
;;;     (setq printstijl (get_tile \"printstijl\"))
     (done_dialog)
    )"
  )
   (action_tile "printstijl" "(setq printstijl (nth (atoi $value) displistprintstijl))"  )
;  ) ;_ end of ACTION_TILE
  (action_tile "cancel" "(setq viewselect \"\")(done_dialog)")
  (start_dialog)
You can go from here, and test things out.  If you need more help, post back.  A tip though, you should end your action_tile calls that have done_dialog, with a number, then you can test that with start_dialog.
ie:
Code: [Select]
(action_tile "accept" "(progn ... do your stuff (done_dialog 1))")
(action_tile "cancel" "(done_dialog 0)")
(if (equal (start_dialog) 1)
 .... do your stuff....
)

Here is the complete code that I have.  I think it will be easier for me to post the whole thing, instead of you trying to add the part I changed into your old code.
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


;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
  (setq ocmd    (getvar "cmdecho")
        ocmddia (getvar "cmddia")
        oexpert (getvar "expert")
        oosmode (getvar "osmode")
  ) ;_ end of SETQ
(command "cmdecho" 0 "cmddia" 1 "expert" 5 "osmode" 0) ;Change variables
  (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


  (init_vars1)
  (make_device_list)
  (init_vars2)
  (make_plotstyle_list)
;;  (init_vars3)
;;  (make_papersize_list)




  (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)
  (action_tile
    "accept"
    "(progn
     (setq viewselect (get_tile \"viewbox\"))
     (setq papierformaat (get_tile \"papierformaat\"))
     (setq printschaal (get_tile \"printschaal\"))
;;;     (setq printstijl (get_tile \"printstijl\"))
     (done_dialog)
    )"
  )
   (action_tile "printstijl" "(setq printstijl (nth (atoi $value) displistprintstijl))"  )
;  ) ;_ end of ACTION_TILE
  (action_tile "cancel" "(setq viewselect \"\")(done_dialog)")
  (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
;;;For debug purpose
;;;          (princ (strcat "\nViewnummer: "
;;;                         (itoa item)
;;;                         "    Viewnaam: "
;;;                         viewnaam
;;;                         " Breedte: "
;;;                         (itoa (fix breedte))
;;;                         " Hoogte: "
;;;                         (itoa (fix hoogte))
;;;                 ) ;_ end of STRCAT
;;;          ) ;_ end of PRINC
;;;          (princ (strcat "\nPapierformaat: "
;;;                         papierformaat
;;;                         "    Papier orientatie: "
;;;                         orientatie
;;;                         "\n"
;;;                        ) ;_ end of strcat
;;;          ) ;_ end of PRINC
             (command "-plot" ; Print view
                      "yes" ;Detailed plot configuration? [Yes/No] <No>
                      "model" ;Enter a layout name or [?] <Model>
                      "Laserjet A3.pc3" ;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:
        printschaal ;Enter plot scale
;(strcat "1=" (itoa schl)) ;Enter plot scale
;"1=5"
                      "Center" ;Enter plot offset
                      "y" ;Plot with plot styles:
                      printstijl ;Enter plot style table name
;" Plotter Normaal.ctb" ;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 "\nGeen views gekozen.....!") ; Display text if no view or cancel is selected
  ) ;_ end of IF
  (command "cmddia" ocmddia "expert" oexpert "osmode" oosmode "cmdecho" ; Reset variables
           ocmd) ;_ end of command
  (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 make_papersize_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-GetCanonicalMediaNames 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

  (defun init_vars3 ()
    (if (not PLOTSIZE-DEVICE)(setq PLOTSIZE-DEVICE "None"))
         (setq  plotsize-list (make_papersize_list))
          (if (and PLOTSIZE-DEVICE (member PLOTSIZE-DEVICE plotsize-list))
      (setq plotsize# (- (length plotsize-list) (length (member PLOTSTYLE-DEVICE plotsize-list)))
      )
      (setq plotsize# 0)
    )
  ) ; End init_vars3

;;===============================================
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 16, 2006, 12:34:53 PM
I am not near a computer with autocad installed.So i can't test it.Thank you for your help so far and i post my findings when i can
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 17, 2006, 02:10:37 AM
I indeed got my dcl on screen and it stays there,but my drop downlist is greyed out and can't figure out why..I don't know what to do further.This is what i got....

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


;Start routine
(defun c:printview2 (/           ocmd        ocmddia     oexpert
                    oosmode     viewlijst   dianummer   viewselect
                    papierformaat           teller      item
                    orientatie  viewnaam    hoogte      breedte
                   ) ;Save values of variables to change
  (setq ocmd    (getvar "cmdecho")
        ocmddia (getvar "cmddia")
        oexpert (getvar "expert")
        oosmode (getvar "osmode")
  ) ;_ end of SETQ
(command "cmdecho" 0 "cmddia" 1 "expert" 5 "osmode" 0) ;Change variables
  (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


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


  (setq dianummer (load_dialog "printview2.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)
  (action_tile
    "accept"
    "(progn
     (setq viewselect (get_tile \"viewbox\"))
     (setq papierformaat (get_tile \"papierformaat\"))
     (setq printschaal (get_tile \"printschaal\"))
;;;     (setq printstijl (get_tile \"printstijl\"))
    (done_dialog)
    )"
  )
;;   (action_tile "printstijl" "(setq printstijl (nth (atoi $value)  plotstyle-list))"  )
;  ) ;_ end of ACTION_TILE
  (action_tile "cancel" "(setq viewselect \"\")(done_dialog)")   
  (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>
                      "Laserjet A3.pc3" ;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:
        printschaal ;Enter plot scale
                      "Center" ;Enter plot offset
                      "y" ;Plot with plot styles:
                      printstijl ;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 "\nGeen views gekozen.....!") ; Display text if no view or cancel is selected
  ) ;_ end of IF
  (command "cmddia" ocmddia "expert" oexpert "osmode" oosmode "cmdecho" ; Reset variables
           ocmd) ;_ end of command
  (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)
    )



 ;;;--- Sort the plotter list
  (setq printstijl(acad_strlsort plotstyle_list))

  ;;;--- Add the list to the dialog box
  (start_list "printstijl" 3)
  (mapcar 'add_list printstijl)
  (end_list)






  ) ; End init_vars2

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

Title: Re: Help with Print Views Routine...
Post by: CAB on March 17, 2006, 08:48:46 AM
I simplified you DCL code & removed the is_enabled=false from
the printstijl pop up list. Try it now.

Code: [Select]
printview : dialog {label = "Print Views 2006";                                                     
  : row {                                                                                           
    : boxed_column { label = "Selecteer Views";                                                     
      : list_box { key = "viewbox";  width = 25; height = 20; multiple_select = true; }             
    }                                                                                               
    : spacer_1 {}                                                                                   
    : column {                                                                                     
      : radio_column { label = "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_1 {}                                                                                 
      : radio_column {  label = "Print Schaal";  key = "printschaal";                               
        : radio_button { label = "1:1";  key = "1=1"; }                                               
        : radio_button { label = "1:2";  key = "1=2"; }                                             
        : radio_button { label = "1:5";  key = "1=5";  value = "1";}                               
        : radio_button { label = "1:10"; key = "1=10"; }                                           
        : radio_button { label = "1:20"; key = "1=20"; }                                           
      }                                                                                             
      : spacer_1 {}                                                                                 
      : boxed_row { label = "Print Stijl";                                                         
        : popup_list { key = "printstijl"; width = 30;}                                             
      }                                                                                             
    }                                                                                               
  }                                                                                                 
  : spacer_1 {}                                                                                     
  ok_cancel ;                                                                                       
}
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 17, 2006, 08:57:30 AM
Thank you CAB.This looks oke it isn't grey-out anymore and it shows all ctb files.
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 17, 2006, 12:26:59 PM
So another question.
Is it possible to assign an default plotstyle (in this routine) and that is shows up in the drop down list when this routine is activated.?
Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 17, 2006, 12:31:07 PM
I'm not sure if this is the way, but once you know which one you want to be the default, find where it is located in the list [ (setq default (vl-position Item List)) ] and then use (set_tile popuplist default).
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 18, 2006, 04:59:42 AM
Isn't there another way.For instance one that reads the acad default plotstyle.?
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 20, 2006, 01:57:21 AM
I can set my variable (printstijl) from my drop downlist.But when selected it gives an error....

; error: bad argument type: consp nil

What am i doing wrong.

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


;Start routine
(defun c:printview2 (/           ocmd        ocmddia     oexpert
                    oosmode     viewlijst   dianummer   viewselect
                    papierformaat           teller      item
                    orientatie  viewnaam    hoogte      breedte
                   ) ;Save values of variables to change
;(setq ocmd    (getvar "cmdecho")
;       ocmddia (getvar "cmddia")
;        oexpert (getvar "expert")
;        oosmode (getvar "osmode")
;  ) ;_ end of SETQ
;(command "cmdecho" 0 "cmddia" 1 "expert" 5 "osmode" 0) ;Change variables
  (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


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


  (setq dianummer (load_dialog "printview2.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)


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

  (action_tile
    "accept"
    "(progn
     (setq viewselect (get_tile \"viewbox\"))
     (setq papierformaat (get_tile \"papierformaat\"))
     (setq printschaal (get_tile \"printschaal\"))
    ;;(setq printstijl (get_tile \"printstijlctb\"))
    (done_dialog)
    )"
  )
 (action_tile "printstijlctb" "(setq printstijl (nth (atoi $value)  printstijlctb))"  )
;;  ) ;_ end of ACTION_TILE
  (action_tile "cancel" "(setq viewselect \"\")(done_dialog)")   
  (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>
      "Laserjet A3.pc3" ;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:
        printschaal ;Enter plot scale
                      "Center" ;Enter plot offset
                      "y" ;Plot with plot styles:
                      printstijl ;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
;;(princ printstijl)      
             (setq teller (+ 1 teller))
           ) ;_ end of REPEAT
    ) ;_ end of PROGN
    (princ "\nGeen views gekozen.....!") ; Display text if no view or cancel is selected
  ) ;_ end of IF
  ; (command "cmddia" ocmddia "expert" oexpert "osmode" oosmode "cmdecho" ; Reset variables
    ;       ocmd) ;_ end of command
  (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

;;===============================================
Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 20, 2006, 12:29:27 PM
Change your action tile part to this.
Code: [Select]
  (action_tile
    "accept"
    "(progn
     (setq viewselect (get_tile \"viewbox\"))
     (setq papierformaat (get_tile \"papierformaat\"))
     (setq printschaal (get_tile \"printschaal\"))
    (setq printstijl (get_tile \"printstijlctb\"))
    (done_dialog)
    )"
  )
  (action_tile "cancel" "(setq viewselect \"\")(done_dialog)")
Then when you hit ok, you will have a number string of what ctb file you selected.  You can get the ctb file from you list like this.
Code: [Select]
(setq ctbFile (nth (atoi printstijl) plotstyle-list))

Does this do what you want?
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 21, 2006, 01:56:06 AM
No id did not.This is what i got.

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


;Start routine
(defun c:printview2 (/           ocmd        ocmddia     oexpert
                    oosmode     viewlijst   dianummer   viewselect
                    papierformaat           teller      item
                    orientatie  viewnaam    hoogte      breedte
                   ) ;Save values of variables to change
;(setq ocmd    (getvar "cmdecho")
;       ocmddia (getvar "cmddia")
;        oexpert (getvar "expert")
;        oosmode (getvar "osmode")
;  ) ;_ end of SETQ
;(command "cmdecho" 0 "cmddia" 1 "expert" 5 "osmode" 0) ;Change variables
  (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


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


  (setq dianummer (load_dialog "printview2.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)


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

  (action_tile
    "accept"
    "(progn
     (setq viewselect (get_tile \"viewbox\"))
     (setq papierformaat (get_tile \"papierformaat\"))
     (setq printschaal (get_tile \"printschaal\"))
     (setq printstijl (get_tile \"printstijlctb\"))
    (done_dialog)
    )"
  )
;; (action_tile "printstijlctb" "(setq printctb (nth (atoi $value)  printstijlctb))"  )
 (action_tile "printstijlctb" "(setq printctb (atoi printstijlctb)  plotstyle-list))"  )



 
;;  ) ;_ end of ACTION_TILE
  (action_tile "cancel" "(setq viewselect \"\")(done_dialog)")   
  (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>
      "Laserjet A3.pc3" ;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:
printschaal ;Enter plot scale
                      "Center" ;Enter plot offset
                      "y" ;Plot with plot styles:
printctb ;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
;;(princ printstijl)      
             (setq teller (+ 1 teller))
           ) ;_ end of REPEAT
    ) ;_ end of PROGN
    (princ "\nGeen views gekozen.....!") ; Display text if no view or cancel is selected
  ) ;_ end of IF
  ; (command "cmddia" ocmddia "expert" oexpert "osmode" oosmode "cmdecho" ; Reset variables
    ;       ocmd) ;_ end of command
  (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

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

[\code]
Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 21, 2006, 04:58:03 PM
Can you post what you are using as the lisp file, and the dcl file, as files.  I think this will help.
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 22, 2006, 01:22:53 AM
Here the two files you requested.
Let me explain a little of what i am trying to achieve.
First of all i found this basic  routine somewhere on the net and added some more options (scale and plotstyle)but i did it with radio buttons and only put in the code my settings .Now i am trying  to make this routine universal (by reading  its plotstyle and printers) so that it will run on any machine no matter what plotstyle is made on that particular system.
But  i can't figure out how to do and solve this.
Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 22, 2006, 11:24:36 AM
I will help when I can, and if you still need help.  Real work has come, and I have to do it.
Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 22, 2006, 02:59:42 PM
See if the attached works for you.
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 23, 2006, 01:52:05 AM
Tim
It works for me.Thank you so much for the help you are giving me.I really appreciate that.
I have added an option for choosing a printer and this is working also.Now i have another question.
Is it possible to set the default printer and plotstyle and that it is immediately shown in the drop down list after starting this routine.?
Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 23, 2006, 11:18:57 AM
You're welcome.

You can set it to a default.  Use "set_tile" and the value (string) you want it to be for default.  So
Code: [Select]
(set_tile "dcl Key" "String Value")
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 23, 2006, 12:28:07 PM
I am not behind a PC with AutoCAD installed right now.I have to wait til tomorrow to test that.

But Again here is another question.
Can lsp read the scalelist (same as used in the plot dialog box).?.
So i can make a drop downlist with these.

Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 23, 2006, 01:04:12 PM
I don't know where that list is stored, or if it is.  If it is, then you can copy it to your own popup_list, but if it's not, then all you have to do is create your own, and then figure out the print scale accordingly.
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 23, 2006, 01:16:52 PM
Maybe in here.

http://www.theswamp.org/index.php?topic=5151.0
Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 23, 2006, 01:23:58 PM
I didn't see it in there.
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 23, 2006, 01:45:15 PM
I thought this
Code: [Select]
setq acadApp (vlax-get-acad-object)
     ThisDwg (vla-get-activedocument acadApp)
     CurLayout (vla-get-activelayout ThisDwg))
(vla-refreshplotdeviceinfo CurLayout)
(vla-getcustomscale CurLayout 'scaleN 'scaleD)
(vla-getpapersize CurLayout 'paperW 'paperH)

was the way to go but apparently not.
Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 23, 2006, 03:29:12 PM
That is getting the current scale and paer size for the active layout.
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 24, 2006, 02:39:36 AM
Code: [Select]
(set_tile "dcl Key" "String Value")
This working great.
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 24, 2006, 06:13:53 AM
And yet another question.I have added an select all and clear all button in my DCL.
How to program this in LSP that when a button is pushed it will select all my views.?
Title: Re: Help with Print Views Routine...
Post by: T.Willey on March 24, 2006, 11:07:54 AM
And yet another question.I have added an select all and clear all button in my DCL.
How to program this in LSP that when a button is pushed it will select all my views.?
This one I'm not sure about.  I put a toggle at the bottom of my dialog boxes, and tell people that if selected it will process all in the list box.  If I have some time today I will look into this, as it is a good question.  Maybe someone will chime in that has more dcl experience.
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 29, 2006, 11:09:21 AM
Quote
it is a good question.
And it seems to a difficult one too because there is no reaction from somebody else.
Title: Re: Help with Print Views Routine...
Post by: CAB on March 29, 2006, 11:35:46 AM
I swear i posted that but i must have been dreaming, cause I did it the other night.
Oh well, here it is.

Code: [Select]
  ;;  CAB start
  (set_tile "viewbox" (if viewselect viewselect "")) ; default to none selected
  (action_tile "sel_all" "(select_all)")
  (action_tile "cle_all" "(set_tile \"viewbox\" \"\")")
  (defun select_all(/ sel)
    (repeat (length viewlijst)
      (cond
        ((null sel) (setq sel '(48)))
        ((setq sel (append sel (list 32 (1+ (last sel))))))
        )
    )
    (set_tile "viewbox" (vl-list->string sel))
  )
  ;;  CAB end vl-list

New DCL
Code: [Select]
printview : dialog {label = "Print Views 2006";                                                     
  : row {                                                                                           
    : boxed_column { label = "Selecteer Views";                                                     
      : list_box { key = "viewbox";  width = 25; height = 20; multiple_select = true; }
      : row {
        : button { label = "&Select All"; key = "sel_all"; }
        : button { label = "&Clear All"; key = "cle_all"; }
      }
    }                                                                                               
    : spacer_1 {}                                                                                   
    : column {                                                                                     
      : radio_column { label = "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_1 {}                                                                                 
      : radio_column {  label = "Print Schaal";  key = "printschaal";                               
        : radio_button { label = "1:1";  key = "1=1"; }                                               
        : radio_button { label = "1:2";  key = "1=2"; }                                             
        : radio_button { label = "1:5";  key = "1=5";  value = "1";}                               
        : radio_button { label = "1:10"; key = "1=10"; }                                           
        : radio_button { label = "1:20"; key = "1=20"; }                                           
      }                                                                                             
      : spacer_1 {}                                                                                 
      : boxed_row { label = "Print Stijl";                                                         
        : popup_list { key = "printstijlctb"; width = 30;}                                             
      }                                                                                             
    }                                                                                               
  }                                                                                                 
  : spacer_1 {}                                                                                     
  ok_cancel ;                                                                                       
}
Title: Re: Help with Print Views Routine...
Post by: MvdP on March 29, 2006, 11:57:20 AM
Thanks you CAB
I am not behind a PC with AutoCAD installed right now.
So i have to wait til tomorrow to implement your code.


CAB i did implement the code you provided and it is not working the way it should be.After hitting the select all button it causes a crash/freeze of AutoCAD.

This what i got.What am i missing here or doing wrong.?

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"
        "Klik op OK om dit venster te sluiten.\n\n"
       )
    )
  )
  ;;--------------------------------------------------------------------



;Start routine
(defun c:printview2 (/           ocmd        ocmddia     oexpert
                    oosmode     viewlijst   dianummer   viewselect
                    papierformaat           teller      item
                    orientatie  viewnaam    hoogte      breedte
                   ) ;Save values of variables to change
;;  (setq ocmd    (getvar "cmdecho")
;;        ocmddia (getvar "cmddia")
;;        oexpert (getvar "expert")
;;        oosmode (getvar "osmode")
;;  ) ;_ end of SETQ
(setvar "cmdecho" 1)


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


 ;;;--- 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)
    (repeat (length viewlijst)
      (cond
        ((null sel) (setq sel '(48)))
        ((setq sel (append sel (list 32 (1+ (last sel))))))
        )
    )
    (set_tile "viewbox" (vl-list->string sel))
  )
  ;;  CAB end vl-list
 
(set_tile "printers" "6")
(set_tile "printstijlctb" "11")
(set_tile "printschaallijst" "2")

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

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


And this the DCL

Code: [Select]
printview : dialog {label = "Print Views 2006";                                                     
: 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";}   //not working yet.
      }

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


Title: Re: Help with Print Views Routine...
Post by: MvdP on April 02, 2006, 05:02:48 AM
Still no luck.
Title: Re: Help with Print Views Routine...
Post by: CAB on April 02, 2006, 10:10:52 AM
Try my lsp & dcl files to see if the functions "Clear ALL" & "Select All" work for you before you make any changes.
I see the file you posted has been changed from the version I was working on.
Title: Re: Help with Print Views Routine...
Post by: MvdP on April 03, 2006, 02:09:59 AM
CAB I tried your version and has the same problem.After hitting the Select All button AutoCAD freezes.
Title: Re: Help with Print Views Routine...
Post by: CAB on April 03, 2006, 09:56:42 AM
I was testing in 2000, I'll test again today in 2004 & 2006.
Title: Re: Help with Print Views Routine...
Post by: CAB on April 03, 2006, 03:23:54 PM
Sorry to report that I tried the routine in 2004 and 2006 & the DCL did fine with Select All & Clear All.
Title: Re: Help with Print Views Routine...
Post by: MvdP on April 04, 2006, 02:23:23 AM
That is very strange.I tried it on severall drawings with 30+ views and it freezes in each and every one.
Title: Re: Help with Print Views Routine...
Post by: CAB on April 04, 2006, 08:40:09 AM
Can you post or send me a test drawing?
Title: Re: Help with Print Views Routine...
Post by: MvdP on April 04, 2006, 09:39:54 AM
Here is a test drawing with a bunch of views.With this file and this routine AutoCAD freezes.And i don't get it why this happens.
Title: Re: Help with Print Views Routine...
Post by: CAB on April 04, 2006, 10:56:37 AM
OK, replace the select_all routine.
Turns out my simple counter was too simple & would not count past 9.

Code: [Select]
  (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)
  )
Title: Re: Help with Print Views Routine...
Post by: MvdP on April 05, 2006, 03:06:45 AM
Thanks CAB it is working great.If you don't mind i have another question which i cant figure out.I have added an toggle in the dcl for setting scale to fit and then i want my pulldownlist to grey-ed ou and then of course set my plot scale to fit. But as mentioned before i cant figure this one out.
Here is the code what i got so far.

Code: [Select]
printview : dialog {label = "Print Views 2006";                                                     
: 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 ;                                                                                       
}



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"
        "Klik op OK om dit venster te sluiten.\n\n"
        "Please report any problems you may have.\n\n"
       )
    )
  )
  ;;--------------------------------------------------------------------



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

(setvar "cmdecho" 1)


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


 ;;;--- 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\" (- 1 (atoi $value))))")

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

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

Title: Re: Help with Print Views Routine...
Post by: CAB on April 05, 2006, 08:09:57 AM
Try this
Code: [Select]
(action_tile "fit" "(mode_tile \"printschaallijst\" (if (= $value \"1\") 1 0))")
Title: Re: Help with Print Views Routine...
Post by: MvdP on April 05, 2006, 09:59:18 AM
This is not working for me..
Title: Re: Help with Print Views Routine...
Post by: MvdP on April 11, 2006, 04:17:29 AM
Previous issue not solved yet but here is another question.
Is it possible to add a quantity dropdown list (as in the common autocad plot dialog)in this routine.
There is as far as i know not a variable in cad.How can this be done so it will pint in sequence the the quantity i select.?
(example 1,2,3,4,1,2,3,4,1,2,3,4  and NOT 1,1,1 2,2,2,3,3,3,4,4,4)
Title: Re: Help with Print Views Routine...
Post by: CAB 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.
Title: Re: Help with Print Views Routine...
Post by: MvdP 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.
Title: Re: Help with Print Views Routine...
Post by: MvdP 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.
Title: Re: Help with Print Views Routine...
Post by: CAB 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
Title: Re: Help with Print Views Routine...
Post by: CADaver 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.
Title: Re: Help with Print Views Routine...
Post by: MvdP on June 06, 2006, 08:19:37 AM
Thanks CAB it is working great.
Title: Re: Help with Print Views Routine...
Post by: MvdP 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

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

Title: Re: Help with Print Views Routine...
Post by: CAB 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
                        )
Title: Re: Help with Print Views Routine...
Post by: CAB on June 07, 2006, 08:42:59 AM
You may want to explore this routine. :-)
http://www.theswamp.org/index.php?topic=1916.0
Title: Re: Help with Print Views Routine...
Post by: MvdP on June 07, 2006, 09:11:47 AM
CAB thanks again it works. And i definitely will take look at your code.