Grrr 发表于 2022-7-5 17:36:18

PUBLISH and Lisp / BlackBox�

Hi guys,
I was scratching my head several months about a question.
 
There are alot routines, containing PLOT command, but my question is about PUBLISH. In the web I didn't found any information about this - is it possible to use that command within LISP, but luckily BlackBox posted his "pseudo-reactor" somewhere and until now I'm trying to figure out how it works (how does it invoke the PUBLISH command) - the real question is on the bottom of my post.
 
This is the main part of his code:

;AUTOMATICPUB 0 and ctrl+s;AUTOMATICPUB 1 and ctrl+s to run the reactor(vl-load-com)(defun Autopublish:StartReactor        () (or *AutopublishReactor*   (setq preferences (vla-get-Preferences (vlax-get-acad-object)))   (setq *AutopublishReactor*   (vlr-docmanager-reactor       nil       '(       (:vlr-documentbecamecurrent . Autopublish:DocumentBecameCurrent)        )   )   ) ) (princ))(defun Autopublish:DocumentBecameCurrent (rea doc) (if (and *AutopublishReactor* (= 1 (getvar 'automaticpub)))   (prompt (strcat "\n : AUTOMATICPUB = "          (itoa (setvar 'automaticpub 0))    )   ) ) (princ))(Autopublish:StartReactor)
I added some variables before that:

   (setq PBCOLLATE (getvar 'PUBLISHCOLLATE))   (setvar "PUBLISHCOLLATE" 1)   (setq PBHATCH (getvar 'PUBLISHHATCH))   (setvar "PUBLISHHATCH" 1)   (setq PBALLSHEETS (getvar 'PUBLISHALLSHEETS))   (setvar "PUBLISHALLSHEETS" 1)   (setq FIELD-EVAL (getvar 'FIELDEVAL))   (setvar "FIELDEVAL" 31)   (setq AUTOPUB (getvar 'AUTOMATICPUB))   (setvar "AUTOMATICPUB" 1)   (setq AUTODWFPUB (getvar 'AUTODWFPUBLISH))   (setvar "AUTODWFPUBLISH" 0)   (setq BACKGROUNDPLT (getvar 'BACKGROUNDPLOT))   (setvar "BACKGROUNDPLOT" 0)   (setvar 'TRAYTIMEOUT 1)
 
And I defined a routine to toggle the AUTOMATICPUB variable:
 

;Toggle the AUTOMATICPUB variable:(defun c:tgAutoPub (/)(if (= (getvar "AUTOMATICPUB") 1) (progn (setvar "AUTOMATICPUB" 0) (if (= (getvar "tilemode") 0) (setvar "tilemode" 1)) (princ "\nPublish Reactor is OFF") );progn true (progn (setvar "AUTOMATICPUB" 1) (setvar 'LTSCALE 1) (setvar 'PSLTSCALE 0) (princ (strcat "\nLTSCALE is set to \"" (rtos(getvar 'LTSCALE) 2 ) "\" ")) (princ (strcat "\nPSLTSCALE is set to \"" (rtos(getvar 'PSLTSCALE) 2 ) "\" ")) (princ "\nPublish Reactor is ON") );progn false);if;(princ (strcat "\nPublish Reactor is " (if (= (getvar 'AUTOMATICPUB) 0) (print "ON" )(print "OFF" )) " ")) (princ))
 
His code works like magic: just set AUTOMATICPUB to 1, and ctrl+S to PUBLISH ALL of the layouts (it ignores the "Model" tab).
 
However, the change I'm trying to do is this:
If I had a list of layouts, for example:

(setq MyLayoutList '("Layout1" "Layout2" "Layout3" "Layout7" "Layout8" ))
Would it be possible to set that reactor to PUBLISH only this list, not the whole LAYOUTSLIST.
The problem is that I don't know how his reactor works and what changes I should apply (if my question is possible).
 
So, that was the main question - now I'll reveal my goal:
I'm trying to display all of the layouts in a listbox (usually I use my favourite LM:FiltListBox subroutine - you know the author!).
Then PUBLISH the selected layoutnames from it. (I did similar routine that works with PLOT).

BIGAL 发表于 2022-7-5 18:02:56

Its not publish but your welcome to use my plot layout range. you just enter 1 8
GETVALS.lsp
plotA3Pdfrange.lsp

Grrr 发表于 2022-7-5 18:27:08

Hi BIGAL,
I don't have problems using PLOT, but I'm attempting to build the same thing using PUBLISH:

; List Layouts in popup list; Select Layouts to plot(defun c:PlotSelected_VLD ( / itm lst BACKGROUNDPLT )   (setq BACKGROUNDPLT (getvar 'BACKGROUNDPLOT))   (setvar "BACKGROUNDPLOT" 0)   (setvar 'TRAYTIMEOUT 1)   (setq lst (LM:FiltListBox "Select Layouts to Plot" (layoutlist) T ))   (foreach itm lst ;; For every 'itm' in the list given by 'lst'   (setvar 'LTSCALE 1)   (setvar 'PSLTSCALE 0)   (setvar 'CTab itm)   (COMMAND"-PLOT" "N" "" "" "" "" "N" "Y")   (princ (strcat "\nPlotting Layout \"" itm "\" "))    ) ;; end foreach   (if (= (getvar "tilemode") 0) (setvar "tilemode" 1)) ; Go back to MSPACE                                       (princ));;------------------=={ Filtered List Box }==-----------------;;;;                                                            ;;;;Displays a list box interface from which the user may   ;;;;select one or more items. Includes an edit box filter   ;;;;to enable the user to filter the displayed list of items. ;;;;------------------------------------------------------------;;;;Author: Lee Mac, Copyright © 2013 - www.lee-mac.com       ;;;;------------------------------------------------------------;;;;Arguments:                                                ;;;;msg - List box dialog title                               ;;;;lst - List of strings to display in the list box          ;;;;mtp - Boolean flag to determine whether the user may      ;;;;      select multiple items (T=Allow Multiple)            ;;;;------------------------------------------------------------;;;;Returns:List of selected items, else nil.               ;;;;------------------------------------------------------------;;(defun LM:FiltListBox ( msg lst mtp / _addlist dch dcl des rtn tmp )   (defun _addlist ( key lst )       (start_list key)       (foreach x lst (add_list x))       (end_list)       lst   )   (if       (and         (setq dcl (vl-filename-mktemp nil nil ".dcl"))         (setq des (open dcl "w"))         (write-line               (strcat                   "filtlistbox : dialog { label = \"" msg "\"; spacer;"                   ": list_box { key = \"lst\"; width = 50; fixed_width = true; height = 15; fixed_height = true; allow_accept = true; "                   "multiple_select = " (if mtp "true" "false") "; }"                   ": edit_box { key = \"flt\"; width = 50; fixed_width = true; label = \"Filter:\"; }"                   "spacer; ok_cancel; }"               )               des         )         (not (close des))         (< 0 (setq dch (load_dialog dcl)))         (new_dialog "filtlistbox" dch)       )       (progn         (_addlist "lst" (setq tmp lst))         (set_tile "lst" (setq rtn "0"))         (set_tile "flt" "*")         (action_tile "lst" "(setq rtn $value)")         (action_tile "flt"               (vl-prin1-to-string                  '(progn                     (setq flt (strcat "*" (strcase $value) "*"))                     (_addlist "lst" (setq tmp (vl-remove-if-not '(lambda ( x ) (wcmatch (strcase x) flt)) lst)))                     (set_tile "lst" (if (< (atoi rtn) (length tmp)) rtn (setq rtn "0")))                   )               )         )         (setq rtn               (if (= 1 (start_dialog))                   (mapcar '(lambda ( x ) (nth x tmp)) (read (strcat "(" rtn ")")))               )         )       )   )   (if (< 0 dch)       (setq dch (unload_dialog dch))   )   (if (and (= 'str (type dcl)) (findfile dcl))       (vl-file-delete dcl)   )   rtn)
This is the other code I use, it will PLOT every selected layout from the listbox, specified from the layoutslist.
 
I always output PDF files and the goal is to quickly concatenate them using PUBLISH and I'm trying to skip any prompts for specifying directories.
Usually I name my layouts with prefix of "A4_L" or "A3_P" or "A2_L" ... "A0_P" then I try to concatenate those with the same prefix and orientation. So I end up with few multipage PDFs containing pages of the same size and orientation (to be plotted easily).

Grrr 发表于 2022-7-5 18:42:15

So.. atleast any explanation on how BlackBox's black magic (reactor) works?
How does the PUBLISH is invoked - is it enough for this just to set the automaticpub variable to 1 within a reactor?
页: [1]
查看完整版本: PUBLISH and Lisp / BlackBox�