乐筑天下

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

[编程交流] 绘图:设置副本数

[复制链接]

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 06:55:57 | 显示全部楼层 |阅读模式
大家好,
我找到了一段代码,用于设置绘图例程中的绘图数量。我曾尝试将其合并到一个用于绘制所有布局的函数中,但它没有设置副本的数量。我是不是完全走错了路?
 
  1. AP3
  2. : dialog
  3. {
  4. label = "Plot All A3";
  5. : edit_box
  6. {
  7. label = "Enter Number of Plots :";
  8. mnemonic = "N";
  9. key = "noc";
  10. alignment = centered;
  11. edit_limit = 3;
  12. edit_width = 3;
  13. value = "";
  14. }
  15. : button       
  16. {
  17. key = "accept";
  18. label = "OK";
  19. is_default = true;
  20. fixed_width = true;
  21. alignment = centered;
  22. }
  23. : errtile
  24. {
  25. width = 34;
  26. }
  27. }

 
 
 
  1. (defun C:AP3 (/ CURRENTTAB noc dcl_id)
  2. [color="red"][color="red"](setq dcl_id (load_dialog "AP3.dcl"))
  3.     (if (not (new_dialog "AP3" dcl_id))
  4. (exit)
  5.     );if
  6. (set_tile "noc" "1")
  7. (mode_tile "noc" 2)
  8. (action_tile "noc" "(setq noc (atof $value))")
  9. (start_dialog)
  10. (unload_dialog dcl_id)
  11. [/color][/color]
  12. (setq CURRENTTAB (getvar "ctab"))
  13. (PlotReactorOFF)
  14. (command "_.-layer" "_LW" "0.13" "CCC_LAYOUT_Dimensions" "")
  15. (if (findfile "T:/Drawing Tools/Templates/CCC2009.dwt")
  16.    (progn
  17.      (command "_.psetupin" (findfile "T:/Drawing Tools/Templates/CCC2009.dwt") "A3")
  18.      (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
  19.        (command "_yes")
  20.      ) ;_ while
  21.      T
  22.    ) ;_ progn
  23. ) ;_ if
  24. (command "_-purge" "a" "*" "N")
  25. (setq CCC_Sheet "A3")
  26. (foreach LAYOUT (layoutlist)
  27. (setvar "ctab" LAYOUT)
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. (command "-plot" "n" "" "A3" "" "n" "y" "n")
  30. (command "_zoom" "e")
  31. (command "updatefield" "all" "")
  32. (command "regenall")
  33. (vlax-put-property (vla-get-Plot (vla-get-ActiveDocument
  34. (vlax-get-acad-object))) "NumberOfCopies" noc)
  35. (command "-plot" "n" "" "A3" "" "n" "y" "y")
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. (setvar "ctab" CURRENTTAB)
  38. (PlotReactorON)
  39. (princ)
  40. )
  41. )
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  43. (defun PlotReactorON nil
  44. (vl-load-com)
  45. ;; © Lee Mac 2010
  46. (  (lambda ( data foo / react )
  47.       (if (setq react
  48.             (vl-some
  49.               (function
  50.                 (lambda ( reactor )
  51.                   (if (eq data (vlr-data reactor)) reactor)
  52.                 )
  53.               )
  54.               (cdar
  55.                 (vlr-reactors :vlr-command-reactor)
  56.               )
  57.             )
  58.           )
  59.         (if (not (vlr-added-p react))
  60.           (vlr-add react)
  61.         )
  62.         (setq react
  63.           (vlr-command-reactor data
  64.             (list
  65.               (cons :vlr-commandwillstart foo)
  66.             )
  67.           )
  68.         )
  69.       )
  70.       (if (vlr-added-p react)
  71.         (princ "\n** Reactor Activated **")
  72.         (princ "\n** Reactor Failed to Activate **")
  73.       )
  74.       react
  75.     )
  76.    "Plot-Reactor"
  77.    'Plot-Callback
  78. )
  79. (princ)
  80. )
  81. (defun PlotReactorOFF nil
  82. (vl-load-com)
  83. ;; © Lee Mac 2010
  84. (  (lambda ( data foo / react )
  85.       (if (setq react
  86.             (vl-some
  87.               (function
  88.                 (lambda ( reactor )
  89.                   (if (eq data (vlr-data reactor)) reactor)
  90.                 )
  91.               )
  92.               (cdar
  93.                 (vlr-reactors :vlr-command-reactor)
  94.               )
  95.             )
  96.           )
  97.         (if (vlr-added-p react)
  98.           (vlr-remove react)
  99.         )
  100.       )
  101.       (if (or (not react) (not (vlr-added-p react)))
  102.         (princ "\n** Reactor Deactivated **")
  103.         (princ "\n** Reactor Failed to Deactivate **")
  104.       )
  105.       react
  106.     )
  107.    "Plot-Reactor"
  108.    'Plot-Callback
  109. )
  110. (princ)
  111. )
  112. (defun Plot-Callback ( reactor arguments )
  113. (vl-load-com)
  114. (if (eq (strcase (car arguments)) "PLOT")
  115.    (LM:Popup "Warning" 64 "Gotcha!!!   Please use the NNRDO Plot tools when plotting standard layouts!!")
  116. )
  117. (princ)
  118. )
  119. (defun LM:Popup ( title flags msg / WSHShell result )
  120. ;; © Lee Mac 2010
  121. (setq WSHShell (vlax-create-object "WScript.Shell"))
  122. (setq result   (vlax-invoke WSHShell 'Popup msg 0 title flags))
  123. (vlax-release-object WSHShell)
  124. result
  125. )
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 07:05:50 | 显示全部楼层
这就是我得到代码的地方。。。。
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Controlling-the-Number-of-Copies-in-a-Plot-Routine/td-p/823809
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 07:14:16 | 显示全部楼层
不确定为什么代码的绘图部分是两次,第一次是单拷贝,第二次是再次执行,但对于noc,不确定为什么这两个选项不在IF do 1或更多中。
 
Woodman回到你的另一篇文章,在开始时添加拨号代码,并在开始时添加NOC代码。我认为这段代码过于复杂了。
 
这可能很有用,您也可以将其用于任何程序,而不是硬编码DCL
 
  1. to use (load "getval")(load "your plot")
  2. ;code for getval
  3. (setq title "Please enter dwg number")
  4. (setq width "   edit_width = 12;")
  5. (setq limit "     edit_limit = 9;")
  6. (ah:getval title width limit)
  7. (setq dwgname item)
  8. ;; Input  Dialog box with variable title
  9. ;; By Ah June 2012
  10. ;; code (ah:getval title)
  11. (defun AH:Getval (title width limit / fo)
  12. (setq fname "C://acadtemp//getval.dcl")
  13. (setq fo (open fname "w"))
  14. (write-line "ddgetval : dialog {" fo)
  15. (write-line " : row {" fo)
  16. (write-line ": edit_box {" fo)
  17. (write-line (strcat "    key = "  (chr 34) "sizze" (chr 34) ";") fo)
  18. (write-line  (strcat " label = "  (chr 34) title (chr 34) ";"  )   fo)
  19. ; these can be replaced with shorter value etc
  20. ;(write-line "     edit_width = 18;" fo)
  21. ;(write-line "     edit_limit = 15;" fo)
  22. (write-line width fo)
  23. (write-line limit fo)
  24. (write-line "   is_enabled = true;" fo)        
  25. (write-line "    }" fo)
  26. (write-line "  }" fo)
  27. (write-line "ok_cancel;}" fo)
  28. (close fo)
  29. (setq dcl_id (load_dialog  "c:\\acadtemp\\getval"))
  30. (if (not (new_dialog "ddgetval" dcl_id))
  31. (exit))
  32. (action_tile "sizze" "(setq item  $value)(done_dialog)")
  33. (mode_tile "sizze" 3)
  34. (start_dialog)
  35. ; returns the value of item
  36. )
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 07:30:00 | 显示全部楼层
比加尔,
我运行plot命令两次,因为第一次它设置页面设置,我需要先设置,这样我可以更新所有字段,因为我的标题栏包含一个图纸尺寸字段。当一切都设置好后,第二次运行命令将进行实际打印。
回复

使用道具 举报

39

主题

180

帖子

141

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
195
发表于 2022-7-6 07:38:15 | 显示全部楼层
为什么使用对话框而不是命令行?下面是一个例程,它会在命令行中询问您“有多少副本”。
试试这个。
[code];;;布局打印18x24(defun c:Tab(/CURRENTTAB)(pltnum)(setq CURRENTTAB(getvar“ctab”))(重复xplta(foreach LAYOUT(layoutlist)(setvar“ctab”LAYOUT)(命令“-plot”“yes”“”“TFC-ENGXER6204.pc3”“拱门c(18x24 in.)”“英寸”“横向”“否”;倒置打印“EXTENTS”“FIT”“0.076012,0.00”“YES”;用PLOTSYTLES“单色”打印。CTB“否”;线宽为“否”的打印;使用打印比例“是”缩放线宽;打印图纸空间最后一个“否”;删除隐藏行“否”;将绘图写入文件“否”;保存对布局的更改“是”);继续绘图))(defun pltnum()(setq numplt(getint“\n输入绘图数:”)(if(=numplt nil)(setq xplt 1)(setq xplt numplt))(if(
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 07:41:25 | 显示全部楼层
我认为将vl put用于NOC比重复使用要好,因为您实际运行的plot命令是按图的数量进行的
10个标签
NOC=4绘图=10次
重复4次绘图=40次
 
优点是你是否想要打印集v的只是生产表,我会排序。最终用户问题。
 
对于小数字,我只需运行我的do 1集多次。
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 07:49:41 | 显示全部楼层
你能看看我的代码这么大,看看有什么问题吗?我看不出哪里出了错。
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 08:02:31 | 显示全部楼层
2.总是先加载defun,最后加载代码,lisp从上到下逐级遍历代码,因此,如果在遍历过程中调用尚未加载的defun,即使它存在于代码中,也会出错(Plotreactor off)
 
foreach LAYOUT(layoutlist)其中是layoutlist代码这是一个defun
 
此外,使用VLide调试时,可以“出错时中断”,您可以在停止时执行“检查”变量之类的操作。Lee mac对此有很好的教程。
 
在代码(princ“wow2”)中进一步放置(princ“wow1”)的简单调试有时会有所帮助。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 09:51 , Processed in 0.497993 second(s), 68 queries .

© 2020-2025 乐筑天下

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