bmolama Posté(e) le 9 mars 2005 Posté(e) le 9 mars 2005 Un grand bonjour à tous les « autocadiens » surtout au tribut de CADXP :) J’ai un problème à régler, :casstet: Toujours dans le souci d’efficacité : je souhaite sélectionner toutes les présentations (espaces papiers) _ bouton droit _ gestion de mise en page _ modifier_ imrimante « par exemple » et changer d’un seul coût le traceur de toutes présentation. (sachant j’ai au moins 50 onglets de présentation pour le m^m projet) Actuellement avec le processus cité ci-dessus , « gestion de mise en page » est en fantôme Qu’est ce qu’il faut faire pour ressusciter « gestion de mise en page »,
chris62 Posté(e) le 9 mars 2005 Posté(e) le 9 mars 2005 Helo, Il faut utiliser le Gestionnaire de mise en page dans le menu fichier.1- Créer ton profil imprimant.2- Utiliser la fonction Publier.3- Selectionnes Publier dans traceur (a gauche) puis Présentation (à droite).4- Seclectionnes l'ensemble des Présentations Attention une foi que toutes les lignes sont en bleu remonte à la première et selectionnes l'imprimant.5- Lances l'impression6- Sauvegarde le nom du projet pour cette config imprimant. J'espère que mes explications te seront utiles , voir compréhensives. @+ Chris
x13 Posté(e) le 9 mars 2005 Posté(e) le 9 mars 2005 Salut J'ai trouvé ce script sur le site suivant http://www.cadchat.com/forums/index.php?s=fbc68490d3c7cecca1364996c06d39eb&showtopic=2871 Si cela peut aider***********************************************************************;SCRPLT - SCRIPT PLOTTING;;SCRPLT.LSP MAINTAINED BY RUSSEL STEFFY; FILES REQUIRED WITH PROGRAM : SCRPLT.DCL; Rev. 1.00 INITIAL VERIFICATION 01MAR00; Rev. 1.01 REVISED SIZE FFEMA 20MAR00; Rev. 1.02 REVISED write-line routine 05JUL00; Rev. 1.03 REVISED TO RETURN LONG FILE NAMES 22AUG00; Rev. 1.04 ADDED MULTIPLE PLOT CAPABILITY 07AUG01; Rev. 1.05 ADDED SPACE IN FOLDER NAME AND SPACE IN FILE NAME SUPPORT 12MAR02; Rev. 1.06 ADDED MULTIPLE FOLDER SUPPORT 12MAR02; Rev. 1.07 ADDED AUTOCAD 2004 SUPPORT 25SEP2003; Rev. 1.08 ADDED MORE PLOT SIZES (LIST) 18DEC2003 ;***ERROR HANDLING***(defun scrplterr (s) (if (/= s "Function cancelled") ; If an error (such as CTRL-C) occurs (princ) (princ (strcat "\nError: " s)) ; while this command is active... );if (princ "\n!!!File plot error!!!") (setq *error* olderr) ;Restore old *error* handler (princ));end scrplterr;***ERROR HANDLING***;***DEFINE C:SCRPLT AND LOCAL VARIABLES***(defun C:SCRPLT (/ olderr plotdcl DIRLST dcl_id PNAME PLTLST DIRN DIRN1 DIRNAMES end_code OUT_UNIT PLTVW READLIST COUNT ITEM SCRLST SCRLEN LSTPOS DWGNAM OPENDWG NOPL SOURCE WINPATH CNT 2CNT SRC SING_CHAR DOSPATH IN_UNIT INLINE pick_no ) ;***DEFINE C:SCRPLT AND LOCAL VARIABLES*** ;***SAVE OLD VARIABLES AND SET NEW VALUES*** (setq olderr *error* ;Save old *error* handler *error* scrplterr) ;Set new *error* handler (setq plotdcl "SCRPLT.DCL") (setq NOPL 1) (setq PLTLST (list "FFEM A0" "FFEM A1" "FFEM A2" "FFEM A3" "FFEM A4" "FFEM E (34.00 x 44.00 Inches)" "FFEM D (34.00 x 22.00 Inches)" "FFEM C (22.00 x 17.00 Inches)" "FFEM B (11.00 x 17.00 Inches)" "FFEM A (11.00 x 8.50 Inches)" "ISO expand B4 (250.00 x 353.00 MM)" "ISO expand B4 (353.00 x 250.00 MM)" "ISO expand B3 (353.00 x 500.00 MM)" "ISO expand B3 (500.00 x 353.00 MM)" "ISO expand B2 (500.00 x 707.00 MM)" "ISO expand B2 (707.00 x 500.00 MM)" "ISO expand B1 (706.00 x 1000.00 MM)" "ISO expand B1 (1000.00 x 706.00 MM)" "ISO B4 (250.00 x 353.00 MM)" "ISO B4 (353.00 x 250.00 MM)" "ISO B3 (353.00 x 500.00 MM)" "ISO B3 (500.00 x 353.00 MM)" "ISO B2 (500.00 x 707.00 MM)" "ISO B2 (707.00 x 500.00 MM)" "ISO B1 (706.00 x 1000.00 MM)" "ISO B1 (1000.00 x 706.00 MM)" "ISO expand A4 (210.00 x 297.00 MM)" "ISO expand A4 (297.00 x 210.00 MM)" "ISO expand A3 (297.00 x 420.00 MM)" "ISO expand A3 (420.00 x 297.00 MM)" "ISO expand A2 (420.00 x 594.00 MM)" "ISO expand A2 (594.00 x 420.00 MM)" "ISO expand A1 (594.00 x 841.00 MM)" "ISO expand A1 (841.00 x 594.00 MM)" "ISO expand A0 (841.00 x 1189.00 MM)" "ISO expand A0 (1189.00 x 841.00 MM)" "ISO A4 (210.00 x 297.00 MM)" "ISO A4 (297.00 x 210.00 MM)" "ISO A3 (297.00 x 420.00 MM)" "ISO A3 (420.00 x 297.00 MM)" "ISO A2 (420.00 x 594.00 MM)" "ISO A2 (594.00 x 420.00 MM)" "ISO A1 (594.00 x 841.00 MM)" "ISO A1 (841.00 x 594.00 MM)" "ISO A0 (841.00 x 1189.00 MM)" "ISO A0 (1189.00 x 841.00 MM)" "ARCH expand E1 (30.00 x 42.00 Inches)" "ARCH expand E1 (42.00 x 30.00 Inches)" "ARCH expand E (36.00 x 48.00 Inches)" "ARCH expand E (48.00 x 36.00 Inches)" "ARCH expand D (24.00 x 36.00 Inches)" "ARCH expand D (36.00 x 24.00 Inches)" "ARCH expand C (18.00 x 24.00 Inches)" "ARCH expand C (24.00 x 18.00 Inches)" "ARCH expand B (12.00 x 18.00 Inches)" "ARCH expand B (18.00 x 12.00 Inches)" "ARCH expand A (9.00 x 12.00 Inches)" "ARCH expand A (12.00 x 9.00 Inches)" "ARCH E1 (30.00 x 42.00 Inches)" "ARCH E1 (42.00 x 30.00 Inches)" "ARCH E (36.00 x 48.00 Inches)" "ARCH E (48.00 x 36.00 Inches)" "ARCH D (24.00 x 36.00 Inches)" "ARCH D (36.00 x 24.00 Inches)" "ARCH C (18.00 x 24.00 Inches)" "ARCH C (24.00 x 18.00 Inches)" "ARCH B (12.00 x 18.00 Inches)" "ARCH B (18.00 x 12.00 Inches)" "ARCH A (9.00 x 12.00 Inches)" "ARCH A (12.00 x 9.00 Inches)" "ANSI expand E (44.00 x 34.00 Inches)" "ANSI expand E (34.00 x 44.00 Inches)" "ANSI expand D (22.00 x 34.00 Inches)" "ANSI expand D (34.00 x 22.00 Inches)" "ANSI expand C (17.00 x 22.00 Inches)" "ANSI expand C (22.00 x 17.00 Inches)" "ANSI expand B (11.00 x 17.00 Inches)" "ANSI expand B (17.00 x 11.00 Inches)" "ANSI expand A (8.50 x 11.00 Inches)" "ANSI expand A (11.00 x 8.50 Inches)" "ANSI E (44.00 x 34.00 Inches)" "ANSI E (34.00 x 44.00 Inches)" "ANSI D (22.00 x 34.00 Inches)" "ANSI D (34.00 x 22.00 Inches)" "ANSI C (17.00 x 22.00 Inches)" "ANSI C (22.00 x 17.00 Inches)" "ANSI B (11.00 x 17.00 Inches)" "ANSI B (17.00 x 11.00 Inches)" "ANSI A (8.50 x 11.00 Inches)" "ANSI A (11.00 x 8.50 Inches)" )) (reverse PLTLST) (progn (setq SOURCE (getfiled "PICK FILE TO GET PATH" (getvar "DWGPREFIX") "DWG" 16))(princ) (setq WINPATH SOURCE DOSPATH SOURCE) ;***STRIP FILENAME FROM END OF STRING*** (while (/= "\\" (substr WINPATH (strlen WINPATH ) 1)) (setq WINPATH (substr WINPATH 1 (- (strlen WINPATH ) 1))) );while NOT \ ;***STRIP FILENAME FROM END OF STRING*** ; PUT DOUBLE QUOTES AROUND FOLDER NAMES AND FILE NAME (setq CNT 1 SRC (strlen DOSPATH) 2CNT 0) (while (< CNT SRC ) (setq SING_CHAR (substr DOSPATH CNT 1)) (if (= SING_CHAR "\\") (progn (if (>= 2CNT 1) (progn (setq DOSPATH (strcat (substr DOSPATH 1 (- CNT 1)) "\"\\\"" (substr DOSPATH (+ CNT 1)(- SRC CNT)) );strcat );setq (setq CNT (+ CNT 1) 2CNT (+ 2CNT 1)) );progn (progn (setq DOSPATH (strcat (substr DOSPATH 1 CNT) "\"" (substr DOSPATH (+ CNT 1)(- SRC CNT)) );strcat );setq (setq CNT (+ CNT 1) 2CNT (+ 2CNT 1)) );progn );if );progn );if (setq SRC (strlen DOSPATH)) (setq CNT (+ CNT 1)) );while (setq DOSPATH (strcat DOSPATH "\"")) ; PUT DOUBLE QUOTES AROUND FOLDER NAMES AND FILE NAME ;***STRIP FILENAME FROM END OF STRING*** (while (/= "\\" (substr DOSPATH (strlen DOSPATH ) 1)) (setq DOSPATH (substr DOSPATH 1 (- (strlen DOSPATH ) 1))) );while NOT \ ;***STRIP FILENAME FROM END OF STRING*** (setq DIRNAMES (strcat DOSPATH"*.DWG")) (prompt "\nCreating directory list file, please wait ... ") (command "SHELL" (strcat "DIR " DIRNAMES "/B/A:-d/O:-n>" DOSPATH"DIR.LST")) ;make dir.lst file (setq IN_UNIT (open (strcat WINPATH"DIR.LST") "r"));open DIR.lst file (setq COUNT 0) (while (setq INLINE (read-line IN_UNIT)) ;read line (progn ;from (setq DIRN (substr INLINE 1 (- (strlen INLINE) 4)));dir.lst (setq COUNT (1+ COUNT)) ;file (if (= COUNT 1) ;construct (progn (setq DIRN1 DIRN) ;DIRLST (setq DIRLST (list DIRN1)) );progn );if ;list (if (= COUNT 2) ;line (setq DIRLST (list DIRN DIRN1)) ;by );if ;line (if (>= COUNT 3) ;from (setq DIRLST (cons DIRN DIRLST)) ;dir.lst );if ;file );progn );while (close IN_UNIT) ;close dir.lst file );progn ;***SAVE OLD VARIABLES AND SET NEW VALUES*** ;***DIALOG BOX TO PICK LISP PROGRAM*** (setq dcl_id (load_dialog plotdcl)) (if (not (new_dialog "scr_plt" dcl_id)) (exit) );if (start_list "SIZELIST") (mapcar 'add_list PLTLST) (end_list) (start_list "PLOTLIST") (mapcar 'add_list DIRLST) (end_list) (action_tile "accept" "(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)") (action_tile "NOPL" "(setq NOPL (atoi $value))") (action_tile "SIZELIST" "(setq pick_no $value)") (action_tile "PLOTLIST" "(setq READLIST $value)") (setq end_code (start_dialog)) (unload_dialog dcl_id) (if (= end_code 0) (exit) );if (if pick_no (setq PNAME (nth (atoi pick_no) PLTLST))) (setq PLTVW "E") (setq COUNT 1)(while (setq ITEM (read READLIST)) (setq SCRLST (cons (nth ITEM DIRLST) SCRLST)) (while (and (/= " " (substr READLIST COUNT 1)) (/= "" (substr READLIST COUNT 1)) );and (setq COUNT (1+ COUNT)) );while (setq READLIST (substr READLIST COUNT )));while (if (= PNAME nil)(setq PNAME "FFEM A3")) (setq SCRLEN (length SCRLST))(setq LSTPOS 0)(setq OUT_UNIT (open (strcat WINPATH"PLT.SCR") "w")) (repeat SCRLEN ;********START REPEAT******** (setq DWGNAM (nth LSTPOS SCRLST)) (setq OPENDWG (strcat "OPEN ""\""WINPATH DWGNAM"\"")) (write-line "QSAVE" OUT_UNIT) ;write cmd.scr file (write-line "CLOSE" OUT_UNIT) (write-line OPENDWG OUT_UNIT) (write-line "ZOOM" OUT_UNIT) (write-line "EXTENTS" OUT_UNIT) (write-line "QSAVE" OUT_UNIT)(repeat NOPL (write-line "(if (= (getvar \"CTAB\") \"Model\")(setq test \"A\")(setq test \"N\"))(princ)" OUT_UNIT) (write-line "PLOT" OUT_UNIT) (write-line "Y" OUT_UNIT) (write-line "(getvar \"CTAB\")" OUT_UNIT) (write-line "\\\\Ffecad\\Acad2004\\Plotters\\XES 8830 HDI.pc3" OUT_UNIT) (write-line PNAME OUT_UNIT) (write-line "I" OUT_UNIT) (write-line "L" OUT_UNIT) (write-line "N" OUT_UNIT) (write-line PLTVW OUT_UNIT) (write-line "F" OUT_UNIT) (write-line "0.00,0.00" OUT_UNIT) (write-line "Y" OUT_UNIT) (write-line "." OUT_UNIT) (write-line "Y" OUT_UNIT) (write-line "(princ test)" OUT_UNIT) (write-line "N" OUT_UNIT) (write-line "N" OUT_UNIT) (write-line "(if (= (getvar \"CTAB\") \"Model\")(princ)(setq test \"N\"))" OUT_UNIT) (write-line "(if (= (getvar \"CTAB\") \"Model\")(princ)(setq test \"N\"))" OUT_UNIT) (write-line "Y" OUT_UNIT) );repeat (setq LSTPOS (+ LSTPOS 1)));repeat *********END REPEAT*********** (write-line "QSAVE" OUT_UNIT) ;write cmd.scr file (close OUT_UNIT) ;close cmd.scr file (setq *error* olderr) ;Restore old *error* handler (command ".SCRIPT"(strcat WINPATH"PLT")) ;plot drawing(princ));scrplt.lsp *********************************************************************** Scrplt.dclscr_plt : dialog { label = "SCRPLT.LSP Rev. 1.08"; : text { label ="Maintained by russ.steffy@ffeminerals.com"; } :row{ : text { label ="With no selection default size = FFEM A3 "; } : edit_box { label = "Number of plots per drawing selected: "; value = "1"; key = "NOPL"; edit_width = 4; } } :row{ : list_box { allow_accept = true; key = "SIZELIST"; height = 12; width = 40; } : list_box { multiple_select = true; key = "PLOTLIST"; height = 12; width = 40; } } ok_cancel;} :)
x13 Posté(e) le 9 mars 2005 Posté(e) le 9 mars 2005 Celui-ci fonctionne bien, ;;; ==========================================================================;;; File : PLOTALL.LSP;;; Purpose : Provides PLOTALL and -PLOTALL commands to plot all paper space;;; layouts in the current drawing, thereby working around the;;; "Layout of order" item in January 2003 Bug Watch.;;; Author : Steve Johnson for Cadalyst magazine.;;; Notes : Expects to find PLOTALL.DCL in search path.;;; Uses AutoCAD 2000+ Visual LISP functions.;;; Only tested on AutoCAD 2000 and 2002.;;; ========================================================================== ;; ---------------------------------------------------------------------------;; Function: C:PLOTALL;; Purpose : Dialogue box version of command to plot all paper space layouts;; in the current drawing.;; Global : PLOTALL-DEVICE: string containing name of plot device, e.g.;; "\\\\server\\plotter" or;; "plotter.pc3";; PLOTALL-QTY: number of each layout to plot;; PLOTALL-ORDER: order in which to plot (string) ;; PLOTALL-REV: reverse order? (boolean: T = reverse);; Local : dclfile: full filename of "PlotAll.dcl" file;; dcl#: DCL ID number;; device-list: list of available plot devices;; order-list: list of order strings;; device#: index number of chosen device in device-list;; order#: index number of chosen order in order-list;; quantity: temporary number of each layout to plot;; --------------------------------------------------------------------------- (defun C:PLOTALL (/ ; Functions init_vars init_tiles call_ok ; Variables dclfile dcl# device-list order-list device# order# quantity ) ;; ---------------------------------------------------------------------------;; Function: init_vars;; Purpose : Sets up variables prior to invoking dialogue box.;; --------------------------------------------------------------------------- (defun init_vars () (if (not PLOTALL-DEVICE) (setq PLOTALL-DEVICE "None")) (if (not PLOTALL-QTY) (setq PLOTALL-QTY 1)) (if (not PLOTALL-ORDER) (setq PLOTALL-ORDER "Alpha")) (setq device-list (plotall_device_list) order-list '("Alpha" "Numeric" "Tab") order# (- (length order-list) (length (member PLOTALL-ORDER order-list))) quantity PLOTALL-QTY ) (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_vars ;; ---------------------------------------------------------------------------;; Function: init_tiles;; Purpose : Sets up dialogue box tiles prior to invoking dialogue box.;; --------------------------------------------------------------------------- (defun init_tiles () (action_tile "accept" "(call_ok)") (start_list "device_list") (foreach one device-list (add_list one) ) (end_list) (start_list "order_list") (foreach one order-list (add_list one) ) (end_list) (set_tile "device_list" (itoa device#)) (set_tile "order_list" (itoa order#)) (set_tile "reverse" (if PLOTALL-REV "1" "0")) (set_tile "quantity" (itoa quantity)) ) ; End init_tiles ;; ---------------------------------------------------------------------------;; Function: call_ok;; Purpose : Callback function for OK button. Ensures a quantity greater than;; 0 and a device other than "None".;; --------------------------------------------------------------------------- (defun call_ok () (if (> (setq quantity (atoi (get_tile "quantity"))) 0) (if (> (setq device# (atoi (get_tile "device_list"))) 0) (progn (setq PLOTALL-DEVICE (nth device# device-list) PLOTALL-ORDER (nth (atoi (get_tile "order_list")) order-list) PLOTALL-REV (= (get_tile "reverse") "1") PLOTALL-QTY quantity ) (done_dialog 1) ) (set_tile "error" "Vous devez choisir un modèle d'imprimante ou de traceur") ) (set_tile "error" "Quantité doit être 1 ou plus") ) ) ; End call_ok ;; Start C:PLOTALL ----------------------------------------------------------- (cond ((not (findfile (setq dclfile "PlotAll.dcl"))) (alert "Cannot find PlotAll.dcl") ) ((< (setq dcl# (load_dialog dclfile)) 0) ; Error (prompt (strcat "\nCannot load " dclfile ".")) ) ((not (new_dialog "plotall_main" dcl#)) ; Error (prompt (strcat "\nProblem with " dclfile ".")) ) (T ; No DCL problems: fire it up (init_vars) (init_tiles) (setq action (start_dialog)) (unload_dialog dcl#) (if (= action 1) (plotall_layouts PLOTALL-DEVICE PLOTALL-QTY PLOTALL-ORDER PLOTALL-REV) ) ) ) (princ)) ; End C:PLOTALL ;; ---------------------------------------------------------------------------;; Function: C:-PLOTALL;; Purpose : Command line version of command to plot all paper space layouts;; in the current drawing.;; Global : PLOTALL-DEVICE: string containing name of plot device;; PLOTALL-QTY: number of each layout to plot;; PLOTALL-ORDER: order in which to plot (string) ;; PLOTALL-REV: reverse order? (boolean: T = reverse);; Local : device: temporary string containing name of plot device;; device-list: list of available plot devices;; order: temporary order in which to plot (string);; rev: temporary reverse order? (boolean: T = reverse);; quantity: temporary number of each layout to plot;; --------------------------------------------------------------------------- (defun C:-PLOTALL (/ device device-list order rev quantity) (if (not PLOTALL-DEVICE) (setq PLOTALL-DEVICE "None")) (if (not PLOTALL-QTY) (setq PLOTALL-QTY 1)) (if (not PLOTALL-ORDER) (setq PLOTALL-ORDER "Alpha")) (setq device (getstring T (strcat "\nPlot device <" PLOTALL-DEVICE ">: "))) (if (= device "") (setq device PLOTALL-DEVICE)) (cond ((= device "None") (prompt "\nMust specify a plot device.") ) ((not (member (strcase device) (mapcar 'strcase (setq device-list (plotall_device_list))) ) ) (foreach one device-list (if (/= one "None") (prompt (strcat one "\n")) ) ) (prompt "Must specify one of the above plot devices.\n") ) (progn (initget "Alpha Numeric Tab") (setq order (getkword (strcat "\nImprime selon un Ordre [Alphabéthique/Numerique/Tab] <" PLOTALL-ORDER ">: " ) ) ) (if order (setq PLOTALL-ORDER order)) (initget "Yes No") (setq rev (getkword (strcat "\nOrdre inverse [Yes/No] <" (if PLOTALL-REV "Yes" "No") ">: " ) ) ) (if rev (setq PLOTALL-REV (= rev "Yes"))) (initget 6) ; Positive integer (setq PLOTALL-DEVICE device quantity (getint (strcat "\nNombre de copies <" (itoa PLOTALL-QTY) ">: ")) ) (if quantity (setq PLOTALL-QTY quantity)) (plotall_layouts PLOTALL-DEVICE PLOTALL-QTY PLOTALL-ORDER PLOTALL-REV) ) ) (princ)) ; End C:-PLOTALL ;; ---------------------------------------------------------------------------;; Function: plotall_device_list;; Purpose : Returns list of strings of all available plot devices.;; Local : curdwg: current drawing object;; pslayout: paper space layout object;; --------------------------------------------------------------------------- (defun plotall_device_list (/ curdwg pslayout) (vl-load-com) (setq curdwg (vla-get-ActiveDocument (vlax-get-Acad-Object)) pslayout (vla-get-Layout (vla-get-PaperSpace curdwg)) ) ; Call RefreshPlotDeviceInfo before GetPlotDeviceNames (vla-RefreshPlotDeviceInfo pslayout) (vlax-safearray->list (vlax-variant-value (vla-GetPlotDeviceNames pslayout)))) ; End plotall_device_list ;; ---------------------------------------------------------------------------;; Function: plotall_layouts;; Purpose : Plots all paper space layouts in current drawing to a specified;; plot device, in the specified quantity.;; Params : DEVICE: string containing name of plot device;; QTY: number of each layout to plot;; ORDER: order in which to plot ("Alpha" "Numeric" "Tab");; REV: boolean: if T, reverse plot order;; Local : curdwg: current drawing object;; layout-array: safearray of a single layout name string;; layout-list: list of layout name strings;; plot: plot object (needed to actually perform plot);; errmsg: returned object from failed plot attempt;; --------------------------------------------------------------------------- (defun plotall_layouts (DEVICE QTY ORDER REV / ; Functions delnth sortlist str_num_sort tab_sort ; Variables curdwg layout-array layout-list plot errmsg) ;; ---------------------------------------------------------------------------;; Function: delnth;; Purpose : Returns a list with the Nth item deleted;; Params : N: index number of item to delete (0 is first item in list);; LST: list to delete from;; Local : #: item counter;; tlst: temporary list;; --------------------------------------------------------------------------- (defun delnth (N LST / # tlst) (setq # 0) (while (and LST (/= # N)) (setq tlst (cons (car LST) tlst) LST (cdr LST) # (1+ #) ) ) (reverse (append (reverse (cdr LST)) tlst)) ) ; End delnth ;; ---------------------------------------------------------------------------;; Function: sortlist;; Purpose : Sorts a list, allowing any function to be used for item comparison.;; Params : LST: list to sort;; FUN: name of function to apply to test for "lower": could be a;; built-in function (e.g. >) or a user defined function,;; possibly defined on the spot using lambda.;; --------------------------------------------------------------------------- (defun sortlist (LST FUN / size # pos high item tmplst) (repeat (1- (setq size (length LST))) (setq # 1 ; Position of 1st item to compare with highest item pos 0 ; Position of initial highest item high (nth 0 LST) ; Value of initial highest item ) (while (< # size) ; Walk through the whole list, finding the highest item (if (apply FUN (list high (setq item (nth # LST)))) ; Test for higher (setq ; Found a higher item, so record its: high item ; value, pos # ; position ) ) (setq # (1+ #)) ; Test next item ) (setq tmplst (cons high tmplst) ; Stick highest item at start of temp list LST (delnth pos LST) ; Delete highest item from main list, size (- size 1) ; and reduce size of main list ) ) (cons (car LST) tmplst) ; Add last (lowest) item to start and return ) ; End sortlist ;; ---------------------------------------------------------------------------;; Function: str_num_sort;; Purpose : Sorts a list of layouts into tab number order.;; Params : LST: list of sublists to sort. Each sublist contains a tab;; number index integer and a layout name string.;; --------------------------------------------------------------------------- (defun str_num_sort (LST / split_str_num str_num_compare) ;; ---------------------------------------------------------------------------;; Function: split_str_num;; Purpose : Divides a string into 3 parts: string prefix, numeric middle and;; string suffix.;; Params : STR: string to split;; Local : #: loop counter/character index;; ch: current character;; slen: string length;; s1: string prefix;; s2: string containing numeric middle;; s3: string prefix;; Returns : Always a list containing a string, a real and a string. If any of;; these elements do not exist, defaults of "", 0.0 and "" are used.;; --------------------------------------------------------------------------- (defun split_str_num (STR / # ch slen s1 s2 s3) (setq # 0 slen (strlen STR) s1 "" ) (while (and (<= (setq # (1+ #)) slen) (not s3)) (if (wcmatch (setq ch (substr STR # 1)) "[0123456789.]") (if s2 (setq s2 (strcat s2 ch)) (setq s2 ch) ) (if s2 (setq s3 (substr STR # 1)) (setq s1 (strcat s1 ch)) ) ) ) (list s1 (if s2 (atof s2) 0.0) (if s3 s3 "")) ) ; End split_str_num ;; ---------------------------------------------------------------------------;; Function: str_num_compare;; Purpose : Compares 2 lists. Each list contains a tab number index integer;; and a layout name string. The tab number is ignored and the;; layout name string is divided into 3 parts: string prefix,;; numeric middle and string suffix. The comparison is then performed;; on the first then second, then third items, then on the string as;; a whole.;; Params : X, Y: lists to compare;; Local : xlist: list of 3 parts derived from X layout name string;; ylist: list of 3 parts derived from Y layout name string;; Returns : T if X < Y, else nil.;; --------------------------------------------------------------------------- (defun str_num_compare (X Y / xlist ylist) (setq xlist (split_str_num (cadr X)) ylist (split_str_num (cadr Y)) ) (if (= (car xlist) (car ylist)) ; if 1st are equal (if (= (cadr xlist) (cadr ylist)) ; if 2nd are equal (if (= (caddr xlist) (caddr ylist)) ; if 3rd are equal (< (cadr X) (cadr Y)) ; then ascending on whole string (< (caddr xlist) (caddr ylist)) ; else ascending on 3rd ) (< (cadr xlist) (cadr ylist)) ; else ascending on 2nd ) (< (car xlist) (car ylist)) ; else ascending on 1st ) ) ; End str_num_compare ;; Start str_num_sort -------------------------------------------------------- (reverse (sortlist LST 'str_num_compare)) ) ; End str_num_sort ;; ---------------------------------------------------------------------------;; Function: tab_sort;; Purpose : Sorts a list of layouts into tab number order.;; Params : LST: list of sublists to sort. Each sublist contains a tab;; number index integer and a layout name string.;; Local : #: index integer counter;; retlst: sorted list to return;; --------------------------------------------------------------------------- (defun tab_sort (LST / # retlst) (setq # 1) (while (< (length retlst) (length LST)) (foreach one LST (if (= (car one) #) (setq retlst (cons one retlst) # (1+ #) ) ) ) ) retlst ) ; End tab_sort ;; Start plotall_layouts ----------------------------------------------------- (vl-load-com) (setq curdwg (vla-get-ActiveDocument (vlax-get-Acad-Object)) layout-array (vlax-make-safearray vlax-vbString '(0 . 0)) ) (vlax-for layout (vla-get-Layouts curdwg) (if (/= (vla-get-Name layout) "Model") (setq layout-list (cons (list (vla-get-TabOrder layout) (vla-get-Name layout)) layout-list ) ) ) ) (cond ((= ORDER "Numeric") (setq layout-list (str_num_sort layout-list)) ) ((= ORDER "Tab") (setq layout-list (tab_sort layout-list)) ) ) (if (not REV) ; Layout list to be reversed? (setq layout-list (reverse layout-list)) ) (foreach layout layout-list (prompt (strcat "\nPlotting layout " (itoa (car layout)) ", \"" (cadr layout) "\"...\n" ) ) (setq layout-array (vlax-safearray-fill layout-array (cdr layout)) plot (vla-get-Plot curdwg) ) (vla-SetLayoutsToPlot plot layout-array) (vla-put-NumberOfCopies plot QTY) (setq errmsg (vl-catch-all-apply 'vla-PlotToDevice (list plot DEVICE))) (if (vl-catch-all-error-p errmsg) (prompt (strcat "\nERROR: Plot failed due to following condition:\n " (vl-catch-all-error-message errmsg) "\n" ) ) ) ) (princ)) ; End plotall_layouts (princ) ;;; ==========================================================================;;; End PLOTALL.LSP;;; ========================================================================== //// -------------------------------------------------------------------------//// File : PlotAll.dcl//// Author : Steve Johnson//// Purpose : Dialogue box definition for PLOTALL command.//// ------------------------------------------------------------------------- /// --------------------------------------------------------------------------/// Turn off error checking/// -------------------------------------------------------------------------- dcl_settings : default_dcl_settings { audit_level = 0; } /// --------------------------------------------------------------------------/// Widget: plotall_main/// This is the main PLOTALL dialogue box./// -------------------------------------------------------------------------- plotall_main : dialog { label = "PlotAll.lsp - Imprime tous les onglets (espace papier) du dessin courant"; : popup_list { key = "device_list"; label = "Imprimante-Traceur "; } spacer; : row { : popup_list { key = "order_list"; label = "Ordre "; } : toggle { key = "reverse"; label = "Ordre Inverse"; } } spacer; : edit_box { key = "quantity"; label = "Quantité"; } spacer; ok_cancel; errtile;} /// --------------------------------------------------------------------------/// End PlotAll.dcl/// -------------------------------------------------------------------------- :)
Messages recommandés
Créer un compte ou se connecter pour commenter
Vous devez être membre afin de pouvoir déposer un commentaire
Créer un compte
Créez un compte sur notre communauté. C’est facile !
Créer un nouveau compteSe connecter
Vous avez déjà un compte ? Connectez-vous ici.
Connectez-vous maintenant