I had to revise this section of your code just to see the dialog box.
(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:
(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.
(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
;;===============================================