乐筑天下

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

[编程交流] 按目标类型隔离

[复制链接]

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 23:52:27 | 显示全部楼层
 
以某种方式
回复

使用道具 举报

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-5 23:56:29 | 显示全部楼层
你好
 
这是我到目前为止设法编写的代码,基于此代码有一些问题
 
1.当要求用户选择实体时,如何防止用户丢失实体?
2.如何用(and)而不是嵌套if来编写主函数(isotyp)
3?
4.为什么osnap没有启动
 
  1. (setq TEMPTARGETLAYERNAME "SG_TEMP")
  2. (setq TEMPTARGETLAYERCOLOR 5)
  3. (setq ISOLATED T)
  4. (setq ISOSET nil) ;_hold isolated layers data
  5. (setq ISOVIS 0) ;_set isolated to frozen or locked
  6. ;;----------------=={ Isolate by type }==---------------------;;
  7. ;;                                                            ;;
  8. ;;  Isolate all drawing's entityes by the choosen             ;;
  9. ;;  target type.                                              ;;
  10. ;;                                                            ;;
  11. ;;------------------------------------------------------------;;
  12. ;;  Author: Shay Gaghe, Copyright © 2014                      ;;
  13. ;;------------------------------------------------------------;;
  14. ;;---Function Syntax : isotyp , unisotype(not active)         ;;
  15. ;;-- Current Version : 0.1                                    ;;
  16. ;;-- Version History : 0.0    Date: 11.04.14                  ;;
  17. ;;------------------------------------------------------------;;
  18. ;;----------------=={ SG:applyToSset }==----------------------;;
  19. ;;                                                            ;;
  20. ;;  set all the givan selection set's members to a gien dxf   ;;
  21. ;;  entry and value.                                          ;;
  22. ;;------------------------------------------------------------;;
  23. ;;  Author: Shay Gaghe, Copyright © 2014                      ;;
  24. ;;------------------------------------------------------------;;
  25. ;;  Arguments:                                                ;;
  26. ;;  sset   - a selection set                                  ;;
  27. ;;  dxfe   - dxf entry to substitue                           ;;
  28. ;;  dxfv   - the new dxf value                                ;;
  29. ;;------------------------------------------------------------;;
  30. (defun SG:applyToSset  (sset dxfe dxfv / e i n)
  31. (setq i 0)
  32. (while (< i (sslength sset))
  33.    (setq e (entget (ssname sset i)))
  34.    (setq n (entmod (subst (cons dxfe dxfv) (assoc dxfe e) e)))
  35.    (setq i (1+ i))
  36.    )
  37. T
  38. )
  39. ;;----------------=={ SG:createLayer }==----------------------;;
  40. ;;                                                            ;;
  41. ;;  creates a new layer withe <name> name and <color> color.  ;;
  42. ;;------------------------------------------------------------;;
  43. ;;  Author: Shay Gaghe, Copyright © 2014                      ;;
  44. ;;------------------------------------------------------------;;
  45. ;;  Arguments:                                                ;;
  46. ;;  name   - a string representing the layer name             ;;
  47. ;;  color  - integer representing the layer color             ;;
  48. ;;------------------------------------------------------------;;
  49. ;;  Returned value:                                           ;;
  50. ;;  entity name of the name created entity                    ;;
  51. ;;------------------------------------------------------------;;
  52. (defun SG:createLayer  (name color)
  53. (entmakex (list '(0 . "LAYER")
  54.           '(100 . "AcDbSymbolTableRecord")
  55.           '(100 . "AcDbLayerTableRecord")
  56.           '(70 . 0)
  57.           (cons 2 name)
  58.           (cons 62 color)
  59.           )
  60.     )
  61. )
  62. ;;----------------=={ SG:applyToAllLayers }==--------------------;;
  63. ;;                                                            ;;
  64. ;;  apply a givan property and value to all drawing layers    ;;
  65. ;;  expet the current current one.                            ;;
  66. ;;------------------------------------------------------------;;
  67. ;;  Author: Shay Gaghe, Copyright © 2014                      ;;
  68. ;;------------------------------------------------------------;;
  69. ;;  Arguments:                                                ;;
  70. ;;  dxfe   - dxf entry to substitue                           ;;
  71. ;;  dxfv   - the new dxf value to apply                       ;;
  72. ;;------------------------------------------------------------;;
  73. (defun SG:applyToAllLayers  (dxfe dxfv / la ob ladef)
  74. (setq ISOLATED T)
  75. (while (setq la (tblnext "LAYER" (null la))) ;_set all layers (except target) to froozen
  76.    (if        (not (equal (cdr (assoc 2 la))
  77.             (getvar "CLAYER")
  78.             ))
  79.      (progn
  80. (setq ob (tblobjname "LAYER" (cdr (assoc 2 la))))
  81. (setq ladef (entget ob))
  82. (setq ISOSET (cons ladef ISOSET))
  83. (if (assoc dxfe ladef)
  84.   (entmod
  85.     (subst
  86.       (cons dxfe dxfv)
  87.       (cons dxfe
  88.             (cdr (assoc dxfe (setq ladef (entget ob)))))
  89.       ladef
  90.       )
  91.     )
  92.   (entmod (append la '((dxfe . dxfv))))
  93.   )
  94. )
  95.      )
  96.    )
  97. )
  98. (defun C:isotyp(/ ent sset i e cl f)
  99. (setvar "CMDECHO" 0) ;_turn off native command text
  100. (setvar "OSMODE" 0) ;_turn off osnap
  101. (command "undo" "m") ;_set undo mark
  102. (if (setq ent ;_ask user to select entity, if user miss it, program is terminated
  103.      (car (entsel
  104.             "\n Select the entity type you want to isolate \n")))
  105.    (if        (setq sset (ssget "_X" (list (assoc 0 (entget ent))))) ;_get all entities of the selected type as a selection set
  106.      (if (< 1 (sslength sset))
  107. (if (not (tblsearch "LAYER" TEMPTARGETLAYERNAME)) ;_make sure the temp layer is not in use
  108.   (if (SG:createLayer ;_create layer
  109.         TEMPTARGETLAYERNAME
  110.         TEMPTARGETLAYERCOLOR)
  111.     (if        (SG:applyToSset sset 8 TEMPTARGETLAYERNAME) ;_move all members of sset to the temp layer
  112.       (progn
  113.         (setvar "clayer" TEMPTARGETLAYERNAME) ;_set temp layer as the current layer
  114.         (cond
  115.           ((eq ISOVIS 0) (SG:applyToAllLayers 70 1)) ;_set all layers exept current to froozen
  116.           ((eq ISOVIS 1) (SG:applyToAllLayers 70 4) ;_set all layers exept current to lock
  117.            ))
  118.         (princ
  119.           (strcat
  120.             "\NAll entities of the type "
  121.             (cdr (assoc 0 (entget (ssname sset 1))))
  122.             " has been isolated"
  123.             )
  124.           )
  125.         ) ;_progn
  126.       (princ "\Ncannot apply properties to selection set")
  127.       ) ;_if
  128.     (princ "\NTemp layer could not e created")
  129.     ) ;_if
  130.   (princ (strcat "\nLayer "
  131.                  TEMPTARGETLAYERNAME
  132.                  "is in use terminate function"
  133.                  )
  134.          )
  135.   ) ;_if
  136. (princ "no entities of this type")
  137. ) ;_if
  138.      (princ "cant get entities from database")
  139.      ) ;_if
  140.    (princ "\nUser didnt select en entity or exit prematurly")
  141.    )
  142. (princ)
  143. )
回复

使用道具 举报

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 00:00:44 | 显示全部楼层
没有回复
 
有那么糟糕是什么意思?
我需要你们的支持!
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 00:02:16 | 显示全部楼层
 
很多用户在这里都有同样的话要告诉你
回复

使用道具 举报

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 00:08:07 | 显示全部楼层
 
什么意思?
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 00:09:22 | 显示全部楼层
如果你不关注你的帖子,那意味着你对输入的内容不满意,一点也不感激,这将向用户发出信号,让他们不再愿意帮助同一个用户。
回复

使用道具 举报

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 00:13:38 | 显示全部楼层
塔瓦是唯一一个有这种态度的人。所有用户都能理解,并非所有用户都有时间和地点关注帖子。我很感激,也很高兴成为这个社区的一员,没有你们,我什么都不知道。
回复

使用道具 举报

4

主题

194

帖子

192

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 00:18:30 | 显示全部楼层
samifox,
 
你真的需要开始做一些自己的研究这里有几个好地方开始,书签他们快速参考;
 
http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff18cb41610ec0a2e719-7a04.htm
 
http://www.lee-mac.com/index.html
 
http://www.afralisp.net/autolisp/
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 00:30 , Processed in 0.640854 second(s), 77 queries .

© 2020-2025 乐筑天下

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