乐筑天下

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

[编程交流] Hatch_关闭。lsp-HAT脚本

[复制链接]

56

主题

256

帖子

230

银币

后起之秀

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

铜币
253
发表于 2022-7-5 13:20:57 | 显示全部楼层 |阅读模式
你好
 
曾经对必须打开“图案填充”对话框才能从现有图案填充中获取固有的道具感到恼火,然后AutoCAD似乎认为图案填充也可以非关联!!!
 
这是我写的一个脚本,我想和大家分享。它只是使用addselected命令来填充选定对象,即使它们可能是非关联的,这将确保终身使用关联图案填充。。。。。。。。
 
它适用于您可以抛出的每种图案填充类型(Anno和背景),同时保留所有完全相同的属性。
我需要得到它,这样它将添加注释比例,但如果源图案填充是注释性的,脚本将为其设置标志。
 
 
现在请告诉我你认为或不认为这件事。
 
 
;; 函数语法
 
Hatch_Off或HOFF
 
;; 关于/注释
  1. ;; ABOUT / NOTES
  2. ;; - Hatches using ADDSELECTED command method, no more Hatch UI (EVER) to pick an existing HATCH.
  3. ;; - Automatically changes the HPASSOC variable to 1 then sets it back,
  4. ;;   upon error or exiting the command.
  5. ;; - First pick the HATCH you want then, select your LWPOLYLINES, CIRCLES or ELLIPSES to HATCH.
  6. ;;   This routine is made to only select closed LWPOLYLINES. An easy way to identify them.
  7. ;;   You can run a script called PSIMPLE to fix you entire drawing in one go. See here >>> http://www.theswamp.org/index.php?topic=19865.msg244786#msg244786
  8. ;; - If you want un-associative HATCH for some reason change '(setvar 'hpassoc 1)' to '0'.
  9. ;; - Automatically selects the newly created HATCH/es.
  10. ;; - Sends draworder of HATCH behind selected objects.

 
;; 完整代码
  1. ;; --------------------------=={ Hatch_Off }==----------------------------
  2. ;; -----------------------------------------------------------------------
  3. ;; AUTHOR & ADDITIONAL CODE
  4. ;; Author:                                        3dwannab, Copyright © 2018.
  5. ;; Error functions:                        LeeMac Help pages. www.lee-mac.com.
  6. ;; ABOUT / NOTES
  7. ;; - Hatches using ADDSELECTED command method, no more Hatch UI (EVER) to pick an existing HATCH.
  8. ;; - Automatically changes the HPASSOC variable to 1 then sets it back,
  9. ;;   upon error or exiting the command.
  10. ;; - First pick the HATCH you want then, select your LWPOLYLINES, CIRCLES or ELLIPSES to HATCH.
  11. ;;   This routine is made to only select closed LWPOLYLINES. An easy way to identify them.
  12. ;;   You can run a script called PSIMPLE to fix you entire drawing in one go. See here >>> http://www.theswamp.org/index.php?topic=19865.msg244786#msg244786
  13. ;; - If you want un-associative HATCH for some reason change '(setvar 'hpassoc 1)' to '0'.
  14. ;; - Automatically selects the newly created HATCH/es.
  15. ;; - Sends draworder of HATCH behind selected objects.
  16. ;; FUNCTION SYNTAX
  17. ;; Short-cut                                HOFF
  18. ;; Long-cut                                        Hatch_Off
  19. ;; VERSION                                        DATE                        INFO
  20. ;; Version 1.0                                26-07-2018                Initial release.
  21. ;; Version 1.01                                27-07-2018                var_hatch_bkgcolouradded to set the hatch background colour to none so that the addselected command doesn't use that instead of the original one picked.
  22. ;; TO DO LIST
  23. ;; Change the polylines to the current boundary attributes of selected hatch boundary.
  24. ;; Put all of the annotative scales to the newly created hatch.
  25. ;; If a hatch exists on the selected polylines then delete them and hatch with new.
  26. ;; Check if it works in different UCS modes. (NOT SURE)
  27. ;; -----------------------------------------------------------------------
  28. ;; ---------------------=={ Hatch_Off START }==---------------------------
  29. (defun c:---LOAD_HATCH_OFF (/) (LOAD "Hatch_Off") (c:HOFF))
  30. (defun c:HOFF () (c:Hatch_Off))
  31. (defun c:Hatch_Off ( /
  32. *error*
  33. ent_1
  34. ent_1_vla
  35. ent_1_data
  36. sel_me
  37. ss_1
  38. tmp
  39. var_cmde
  40. var_hatch_ass
  41. var_hatch_bkgcolour
  42. var_os
  43. )
  44. (setq *error* LM:error)
  45. (LM:startundo)
  46. (setq var_cmde (getvar "cmdecho"))
  47. (setq var_hatch_anno (getvar "hpannotative"))
  48. (setq var_hatch_ass (getvar "hpassoc"))
  49. (setq var_hatch_bkgcolour (getvar "hpbackgroundcolor"))
  50. (setq var_os (getvar "osmode"))
  51. (setvar 'cmdecho 0)
  52. (setvar 'osmode 0)
  53. (setvar 'hpbackgroundcolor ".")
  54. (while
  55. (not
  56.         (and
  57.                 (setq
  58.                         ent_1 (car (entsel "\nPlease select a HATCH to copy.\n: ------------------------------ :\n\nThen select any closed LWPOLYLINE's, CIRCLE's or ELLIPSE's.\n"))
  59.                         ent_1_data (if ent_1 (entget ent_1))
  60.                         )
  61.                 (= (cdr (assoc 0 ent_1_data)) "HATCH")
  62.                 (sssetfirst nil)
  63.                 (setq ent_1_vla (vlax-ename->vla-object ent_1))
  64.                 (progn
  65.                         (setq ent_last (entlast)
  66.                                 sel_me (ssadd)
  67.                                 )
  68.                         (while (setq tmp (entnext ent_last)) (setq ent_last tmp))
  69.                         (princ "\nNow select your objects to be HOFF'ified !\n")
  70.                         (setq ss_1 (ssget '(
  71.                                 (-4 . "<OR")
  72.                                 (-4 . "<AND") (0 . "LWPOLYLINE") (70 . 1) (-4 . "AND>")
  73.                                 (-4 . "<AND") (0 . "CIRCLE,ELLIPSE") (-4 . "AND>")
  74.                                 (-4 . "OR>")
  75.                                 )))
  76.                         (if        (IsAnno-p (vlax-ename->vla-object ent_1))
  77.                                 (setvar 'hpannotative 1)
  78.                                 )
  79.                         (setvar 'hpassoc 1)
  80.                         (if ss_1
  81.                                 (progn
  82.                                         (command "_.addselected" "_non" ent_1 "_S" ss_1 "" "" )
  83.                                         (command "._draworder" (entlast) "" "_U" ss_1 "")
  84.                                         (while (setq ent_last (entnext ent_last))
  85.                                                 (ssadd ent_last sel_me)
  86.                                                 )
  87.                                         (sssetfirst nil sel_me)
  88.                                         (princ (strcat "\nYou've been HOFF'd with < "(itoa (sslength ss_1)) (if (> (sslength ss_1) 1) " > objects" " object") " hatched.\n"))
  89.                                         )
  90.                                 )
  91.                         )(princ)
  92.                         )
  93.         )
  94. )
  95. (*error* nil)(princ)
  96. )(princ)
  97. ;; -----------------------------------------------------------------------
  98. ;; ----------------------=={ Functions START }==--------------------------
  99. (vl-load-com)
  100. (defun IsAnno-p (ent / exd ano)
  101. (vl-load-com)
  102. (and (eq (vla-get-HasExtensionDictionary ent) :vlax-true)
  103.         (setq exd (vla-GetExtensionDictionary ent)
  104.                 exd (vla-item exd "AcDbContextDataManager")
  105.                 ano (vla-item exd "ACDB_ANNOTATIONSCALES")
  106.                 )
  107.         (not (zerop (vla-get-Count ano)))
  108.         )
  109. )
  110. (defun LM:error (errmsg)
  111. (and acDoc (vla-EndUndoMark acDoc))
  112. (and errmsg
  113.         (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*"))
  114.         (princ (strcat "\n<< Error: " errmsg " >>\n"))
  115.         )
  116. (setvar 'cmdecho var_cmde)
  117. (setvar 'hpassoc var_hatch_ass)
  118. (setvar 'osmode var_os)
  119. (setvar 'hpannotative var_hatch_anno)
  120. (setvar 'hpbackgroundcolor var_hatch_bkgcolour)
  121. (princ (strcat "\nNo HOFF for you today !\n"))
  122. ) (princ)
  123. (defun LM:startundo ()
  124. (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  125. (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc))
  126. ) (princ)
  127. ;; -----------------------------------------------------------------------
  128. ;; -----------------------=={ Functions END }==-- ------------------------
  129. (princ "\nHatch_Off loaded | Version 1.0 | by 3dwannab.\n")
  130. (princ "\nType "Hatch_Off" OR "HOFF" to run.\n") (princ)
  131. ;; -----------------------------------------------------------------------
  132. ;; ----------------------=={ Hatch_Off END }==----------------------------
  133. ;; EOL
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 13:55:48 | 显示全部楼层
我的工作主要是关于回路和端子连接图,所以我自己很少使用hatch,但它似乎很管用。我唯一想改变的是(这只是一个味道的问题,所以请随意2不同意)和它的外观,你给用户提示选择图案填充和对象谁想要在同一时间被图案填充。所以我的第一个想法是,我是先选择普林还是哈奇?当然,这只是第一次使用,下次你知道。。。对于一个办公室制茶师来说也不错:-)
回复

举报

56

主题

256

帖子

230

银币

后起之秀

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

铜币
253
发表于 2022-7-5 14:17:33 | 显示全部楼层
 
非常感谢。我赚的不仅仅是T!!
 
我只是有点理解Lisp程序。
 
我接受了你的建议,并添加了一个对象选择原则。
 
第一个entget提示输入图案填充,屏幕显示如下。
我想遵循获取和继承道具的工作流程。ssget不能在屏幕上显示AFAIK提示。
 
142102pnuc0pztn07o4b00.jpg
 
将上述代码更新为v1.01。如果设置了该变量,背景色将被覆盖的轻微错误。
回复

举报

56

主题

256

帖子

230

银币

后起之秀

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

铜币
253
发表于 2022-7-5 14:39:26 | 显示全部楼层
我试着让它与嵌套图案填充一起工作,这样我也可以选择那些图案填充,但我得到了错误。
 
这是我正在使用的代码片段。
  1. (command "_.addselected" (car (nentsel))) "_S" pause "" "" )

 
回复

举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-15 08:51 , Processed in 1.424415 second(s), 62 queries .

© 2020-2025 乐筑天下

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