Author Topic: Batch print views..  (Read 2126 times)

0 Members and 1 Guest are viewing this topic.

MvdP

  • Guest
Batch print views..
« on: February 14, 2006, 09:36:07 AM »
Is there some kind of routine that can batch print all views in MS.
No mather what if the view is Portrait or Landscape.?
No LAYOUT  because that can be done in AutoCAd 2006)

Thanks in advance ....

MvdP

  • Guest
Re: Batch print views..
« Reply #1 on: February 17, 2006, 03:31:18 AM »
Nothing yet..So here is an other question.

Can all my views automaticly transported/transverted  to layouts.???

MvdP

  • Guest
Re: Batch print views..
« Reply #2 on: March 09, 2006, 09:04:49 AM »
Nothing.....!!!

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Batch print views..
« Reply #3 on: March 09, 2006, 09:06:11 AM »
that might be possible
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Batch print views..
« Reply #4 on: March 09, 2006, 09:06:31 AM »
Im going to look something up, and I think it can be done
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Batch print views..
« Reply #5 on: March 09, 2006, 09:10:15 AM »
from a PS, in a viewport, I was able to restore a view.  So, in theory, yes it can be done.  Now we need to figure out how to program it.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Batch print views..
« Reply #6 on: March 09, 2006, 09:36:31 AM »
This may help, it's prqtty well undocumented
'R. Robert Bell
Private Sub VP2006()
  Dim myVPort As IAcadPViewport2
  Set myVPort = ThisDrawing.ActivePViewport

  Dim msView As IAcadView2
  Set msView = myVPort.ModelView
  myVPort.SyncModelView
End Sub

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: Batch print views..
« Reply #7 on: March 09, 2006, 11:13:35 AM »
I wrote one sometime ago for r12, let me see if I can find it.
I drink beer and I know things....

Bob Wahr

  • Guest
Re: Batch print views..
« Reply #8 on: March 09, 2006, 02:51:27 PM »
Cheap and dirty, could have plotted programatically but decided to command line it instead out of laziness
Code: [Select]
Sub test()
Dim Vyoo As AcadView
Dim Vyues As AcadViews
Set Vyues = ThisDrawing.Views
For Each Vyoo In Vyues
  ThisDrawing.SendCommand "-PLOT" & vbCr & "y" & vbCr & "Model" & vbCr & _
  "PLOTTER NAME HERE" & vbCr & "PAPER SIZE HERE" & vbCr & "I" & vbCr & "L" & vbCr & "N" _
  & vbCr & "v" & vbCr & Vyoo.Name & vbCr & "f" & vbCr & "C" & vbCr & "Y" & _
  vbCr & "SOME CTB FILE NAME WITHOUT EXTENSION HERE" & vbCr & "Y" & vbCr & "n" & vbCr & vbCr & "n" & vbCr & "y" & vbCr
Next Vyoo
End Sub

Bob Wahr

  • Guest
Re: Batch print views..
« Reply #9 on: March 09, 2006, 02:52:36 PM »
That of course is in answer to question 1 not question 2.

MvdP

  • Guest
Re: Batch print views..
« Reply #10 on: March 10, 2006, 01:51:38 AM »
Bob Wahr
This is maybe a stupid question but what to do with the code you posted.?

MvdP

  • Guest
Re: Batch print views..
« Reply #11 on: March 10, 2006, 08:29:43 AM »
Found this routine one the net. (Made by Simon Weel)
But can't get it to work in AutoCAD 2006 help would be appreciated.
If understand it correctly this routine should automaticly print all selected views no matter if the view is in Landscape or Portrait.

Code: [Select]
;Routine om een gekozen aantal views af te drukken. 17-08-2004.
 ;(c) 2004 Siem Weel
;;; Use this for a list of the views:
;;; (GetNames "view")
;;; Use this for the number of views:
;;; (length (GetNames "view"))

(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
  (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\"))(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:
                      (strcat "1=" (itoa sch)) ;Enter plot scale
                      "Center" ;Enter plot offset
                      "y" ;Plot with plot styles:
                      "-2 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;;;;;;;;


Code: [Select]
printview : dialog {label = "Views afdrukken";
: row {
: boxed_column {
        label = "Selecteer views:";
        : list_box {
//              fixed_width_font = true;
                key = "viewbox";
                width = 25;
                height = 25;
                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";
                                key = "A4";
                        }
                        : radio_button {
                                label = "ISO A3 (297.00 x 420.00 MM)";
                                key = "ISO A3 (297.00 x 420.00 MM)";
                                value = "1";
                        }
                } // End radiocolumn
        } // End row
} // End column
} // End row
: spacer_1 {}
   ok_cancel;
} // End dialog



« Last Edit: March 13, 2006, 05:45:54 AM by MvdP »

MvdP

  • Guest
Re: Batch print views..
« Reply #12 on: March 14, 2006, 01:30:42 AM »
Finally i got it working.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Batch print views..
« Reply #13 on: March 14, 2006, 03:49:24 AM »
MvdP
What was wrong, what did you change ?
can you post the revised code ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MvdP

  • Guest
Re: Batch print views..
« Reply #14 on: March 14, 2006, 04:38:28 AM »
Revised code for my needs.
Some things can be improved for instance:
- Select printer/ plotter from drop downlist
- Select plotstyle from drop downlist
- Select scale from drop downlist

So who wants too.?

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
  (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\"))(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:
;;(strcat "1=" (itoa schl)) ;Enter plot scale
                       "1=5"
                      "Center" ;Enter plot offset
                      "y" ;Plot with plot styles:
                      "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;;;;;;;;



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
} // End column
} // End row
: spacer_1 {}
   ok_cancel;
} // End dialog

« Last Edit: March 14, 2006, 04:43:03 AM by MvdP »