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

0 Members and 1 Guest are viewing this topic.

MvdP

  • Guest
Help with Print Views Routine...
« 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




T.Willey

  • Needs a day job
  • Posts: 5251
Re: Help with Print Views Routine...
« Reply #1 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?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #2 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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Help with Print Views Routine...
« Reply #3 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

;;===============================================
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #4 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

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #5 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

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

« Last Edit: March 17, 2006, 02:23:54 AM by MvdP »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help with Print Views Routine...
« Reply #6 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 ;                                                                                       
}
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 #7 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.

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #8 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.?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Help with Print Views Routine...
« Reply #9 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).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #10 on: March 18, 2006, 04:59:42 AM »
Isn't there another way.For instance one that reads the acad default plotstyle.?

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #11 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

;;===============================================
« Last Edit: March 20, 2006, 02:19:23 AM by MvdP »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Help with Print Views Routine...
« Reply #12 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?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MvdP

  • Guest
Re: Help with Print Views Routine...
« Reply #13 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]

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Help with Print Views Routine...
« Reply #14 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.