FastFiber

Help met Print Views Routine...

Gestart door Marcel, di 28 03 2006, 07:48:56

Vorige topic - Volgende topic

Marcel

IK heb op het internet een routine gevonden die geselecteerde  views automatsich plot(Orientatie word geregeld).Ik heb hier wat aan gesleuteld maar ik kom er niet helemaal uit.Ik heb in mijn DCl twee button's toegevoegd waarmee ik alle aanwezige views in mijn list -box wil (de-) selecteren.Hoe doe ik dat.?


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 ;                                                                                       
}



(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 \"printschaal\"))
      (setq printschaal (get_tile \"printschaallijst\"))
     (setq printers (get_tile \"printers\"))
     (setq printctb (get_tile \"printstijlctb\"))
    (done_dialog)
    )"
  )

 
;;  ) ;_ end of ACTION_TILE
(set_tile "printers" "6")
(set_tile "printstijlctb" "11")
(set_tile "printschaallijst" "2")

;;(action_tile "fit" (do_stempel)(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:
;; printschaal ;Enter plot scale
(nth (atoi printschaal) printschaallijst)
                      "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

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


Marcel

Ik ben eruit en hier is de complete code.


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 ;                                                                                       
}




(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:printview (/           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 "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)


;;;--- 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 "Fit" "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" "3")
   
(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

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



EddyBeerke

Citaat van: Marcel op di 06 06 2006, 15:00:55

...
  : 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";}
...


In dit stukje kun je dus het papierformaat kiezen.
Ik zoek eigenlijk een stukje lisp die het papieformaat van een gekozen printer/plotter weergeeft.
Is dit mogelijk en zo ja, hoe dan?
Civil3d 2026, Blender 4.x gebruiker
Gebruiker sinds AutoCAD R12

http://eddylucas.c1.biz/
https://www.google.com/maps/contrib/109381066561676463628/photos/

roy_043

Volgens mij niet helemaal wat je zoekt:
Met de functie vla-GetPaperSize kun je het plotformaat van een layout opvragen.
http://forums.cadalyst.com/showthread.php?t=5234&page=2
http://discussion.autodesk.com/forums/thread.jspa?threadID=479253

EddyBeerke

Citaat van: roy_043 op vr 05 03 2010, 20:26:14
...
http://discussion.autodesk.com/forums/thread.jspa?threadID=479253

Deze link is eigenlijk wat ik nodig heb voor mijn Lisp.
Ik ga 't even uitpluizen wat ik hiervan wil gebruiken.
Maar het is zeer bruikbaar, dus bij deze bedankt!
Civil3d 2026, Blender 4.x gebruiker
Gebruiker sinds AutoCAD R12

http://eddylucas.c1.biz/
https://www.google.com/maps/contrib/109381066561676463628/photos/