乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 84|回复: 3

[编程交流] PUBLISH and Lisp / BlackBox�

[复制链接]

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 2022-7-5 17:36:18 | 显示全部楼层 |阅读模式
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:
  1. ;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[blackBox] : AUTOMATICPUB = "            (itoa (setvar 'automaticpub 0))    )   ) ) (princ))(Autopublish:StartReactor)
I added some variables before that:
  1.    (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:
 
  1. ;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:
  1. (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).
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 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
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 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:
  1. ; 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).
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 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?
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 03:20 , Processed in 0.871342 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表