I am creating a routine that must be able to do the following.
I want the select views (this part is working) and create a pdf with the name of the view(this part is not).
How can this be done.?
Update...
I found a way to name pdf file the same as view, but how can i make
it to use and write it into the current project directory (dwgprefix).?
(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
"Klik op OK om dit venster te sluiten.\n\n"
)
)
)
;;--------------------------------------------------------------------
;Start routine
(defun c:view2pdf (/ ocmd ocmddia oexpert
oosmode viewlijst dianummer viewselect
papierformaat teller item
orientatie viewnaam hoogte breedte
) ;Save values of variables to change
;;(setvar "cmdecho" 0)
(setvar "filedia" 0)
(setq viewlijst ;Get list of views and sort it
(vl-sort (getnames "view")
(function (lambda (a b) (< (nth 0 a) (nth 0 b))))
) ;_ end of VL-SORT
) ;_ end of SETQ
(setq dianummer (load_dialog "view2pdf.DCL")) ;Start dialog to select views
(new_dialog "view2pdf" dianummer)
(setq teller 0)
(setq schaall (rtos(getvar "userr1")))
(start_list "viewbox")
(repeat (length viewlijst)
(add_list (car (nth teller viewlijst)))
(setq teller (+ 1 teller))
) ;_ end of REPEAT
(end_list)
(setq printschaallijst(list "1:1" "1:2" "1:5" "1:10" "1:20" "1:50" "1:100" "1:200" "1:500" "1:1000"))
(start_list "printschaallijst")
(mapcar 'add_list printschaallijst)
(end_list)
(setq printstijlctb (list
"Plotter Dun.ctb"
"Plotter Middel.ctb"
"Plotter Normaal.ctb"))
(start_list "printstijlctb")
(mapcar 'add_list printstijlctb)
(end_list)
(setq papierformaatlijst (list
"ISO A4 (210.00 x 297.00 MM)"
"ISO A3 (297.00 x 420.00 MM)"
))
(start_list "papierformaatlijst")
(mapcar 'add_list papierformaatlijst)
(end_list)
(action_tile
"accept"
"(progn
(setq viewselect (get_tile \"viewbox\"))
(setq papierformaat (get_tile \"papierformaatlijst\"))
(setq printschaal (get_tile \"printschaallijst\"))
(setq printctb (get_tile \"printstijlctb\"))
(done_dialog)
)"
)
;; ) ;_ end of ACTION_TILE
;; CAB start
(setq schaal (rtos(getvar "userr1")))
(setq dwgsch (strcat "1:" schaal))
(set_tile "viewbox" (if viewselect viewselect "")) ; default to none selected
(action_tile "selall" "(select_all)")
(action_tile "clrall" "(set_tile \"viewbox\" \"\")")
(defun select_all (/ sel cnt)
(setq cnt 0
sel ""
)
(repeat (length viewlijst)
(setq sel (strcat sel (itoa cnt) " "))
(setq cnt (1+ cnt))
)
(set_tile "viewbox" sel)
)
;; CAB end vl-list
(set_tile "papierformaatlijst" "1")
(set_tile "printstijlctb" "2")
(set_tile "printschaallijst" "2")
(set_tile "schaall" dwgsch)
(action_tile "fit" "(mode_tile \"printschaallijst\" (if (setq fitflag (= $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>
"DWG To PDF.pc3" ;Enter an output device name
(nth (atoi papierformaat) papierformaatlijst);Enter paper size:
"M" ;Inches/milimeters
orientatie ;Enter drawing orientation:
"n" ;Plot upside down:
"view" ;Enter plot area:
viewnaam ;Enter view name:
(if fitflag "Fit" (vl-string-translate ":" "=" (nth (atoi printschaal) printschaallijst))) ;Enter plot scale
"Center" ;Enter plot offset
"y" ;Plot with plot styles:
(nth (atoi printctb) printstijlctb) ;Enter plot style table name
"y" ;Plot with lineweights:
"n" ;Remove hidden lines
vienaam ;enter file name name of view.!!use fwgprefix for dir.
"n" ;save changes to page setup [Yes/No] <No>
"y" ;Proceed with plot [Yes/No] <Y>:
) ;_ end of COMMAND
(setq teller (+ 1 teller))
) ;_ end of REPEAT
) ;_ end of PROGN
(princ "\nJe hebt geen views geselecteerd en er is dus ook niets geprint.....!")
) ;_ end of IF
(setvar "filedia" 1)
(setvar "cmdecho" 1)
(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;;;;;;;;