明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 7871|回复: 6

[讨论] 如何修改块以及块中的块的图层

[复制链接]
发表于 2014-4-14 12:32:54 | 显示全部楼层 |阅读模式
选择一个块:
然后
1\修改这个块所在的图层,
2\修改该块内图元所在的图层
3\修改块内块所在的图层,以及块内块的图元所在的图层(如果这个块内有块的话)
请问如何实现呢?
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2014-4-14 13:56:50 | 显示全部楼层
方法:
1、当初就设定好实体的图层
2、refedit在位编辑改实体图层
 楼主| 发表于 2014-4-14 14:15:36 | 显示全部楼层
xyp1964 发表于 2014-4-14 13:56
方法:
1、当初就设定好实体的图层
2、refedit在位编辑改实体图层

程序,而不是人工的办法
发表于 2014-4-14 14:25:29 | 显示全部楼层
仅供参考:

  1. ;; 需要e派工具箱(XCAD)的支持:http://yunpan.cn/QXQKsW9gAPmpF
  2. ;; 图块内实体改图层并颜色随层
  3. (defun c:test1149 (/ ilst ll1 ll2)
  4.   (xyp-CMDLA0)
  5.   (defun main-pro (/ s1 lst la a)
  6.     (if        (setq s1 (xyp-entsel "图块" "insert"))
  7.       (progn
  8.         (setq la (nth (atoi po1) lst1))
  9.         (vlax-for a (xyp-Block-Item s1)
  10.           (vla-put-layer a la)                ; 改图层
  11.           (vla-put-color a acbylayer)        ; 颜色随层
  12.         )
  13.       )
  14.     )
  15.     (xyp-regen)
  16.   )
  17.   (xyp-initSet '(po1) '("0") )
  18.   (setq lst1 (xyp-get-layers)
  19.         ilst '(("po1" "图层" "poplist" "lst1" "8") "spacer;")
  20.   )
  21.   (if (= (xyp-Dcl-Init Ilst "【改块图层】" t) 1)
  22.     (main-pro)
  23.   )
  24.   (xyp-CMDLA1)
  25. )
 楼主| 发表于 2014-4-14 18:03:28 | 显示全部楼层
xyp1964 发表于 2014-4-14 14:25
仅供参考:

不是代码的代码,
发表于 2014-4-15 12:57:58 | 显示全部楼层
本帖最后由 菜卷鱼 于 2014-4-15 12:59 编辑

http://lee-mac.com/applytoblockobjects.html

  1. ;; Apply to Block Objects  -  Lee Mac
  2. ;; Evaluates a supplied function on all objects in a block definition.
  3. ;; Arguments:
  4. ;; blks - VLA Block Collection in which block resides
  5. ;; name - Block name
  6. ;; func - function to apply to all objects in block
  7. ;; Returns a list of results of evaluating the function, else nil.

  8. (defun LM:ApplytoBlockObjects ( blks name func / def result )
  9.     (setq func (eval func))
  10.     (if (not (vl-catch-all-error-p (setq def (vl-catch-all-apply 'vla-item (list blks name)))))
  11.         (vlax-for obj def (setq result (cons (func obj) result)))
  12.     )
  13.     (reverse result)
  14. )

The following example program will move all objects in a block to Layer "0".
  1. (defun c:test ( / s )
  2.     (princ "\nSelect Block: ")
  3.     (if (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
  4.         (LM:ApplytoBlockObjects
  5.             (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
  6.             (vla-get-effectivename (vlax-ename->vla-object (ssname s 0)))
  7.            '(lambda ( obj ) (vla-put-layer obj "0"))
  8.         )
  9.     )
  10.     (princ)
  11. )
  12. (vl-load-com) (princ)





发表于 2014-9-14 23:42:46 | 显示全部楼层
对多层嵌套块不完美
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-1 12:57 , Processed in 0.171298 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表