如何修改块以及块中的块的图层
选择一个块:然后
1\修改这个块所在的图层,
2\修改该块内图元所在的图层
3\修改块内块所在的图层,以及块内块的图元所在的图层(如果这个块内有块的话)
请问如何实现呢?
方法:
1、当初就设定好实体的图层
2、refedit在位编辑改实体图层 xyp1964 发表于 2014-4-14 13:56 static/image/common/back.gif
方法:
1、当初就设定好实体的图层
2、refedit在位编辑改实体图层
程序,而不是人工的办法 仅供参考:
;; 需要e派工具箱(XCAD)的支持:http://yunpan.cn/QXQKsW9gAPmpF
;; 图块内实体改图层并颜色随层
(defun c:test1149 (/ ilst ll1 ll2)
(xyp-CMDLA0)
(defun main-pro (/ s1 lst la a)
(if (setq s1 (xyp-entsel "图块" "insert"))
(progn
(setq la (nth (atoi po1) lst1))
(vlax-for a (xyp-Block-Item s1)
(vla-put-layer a la) ; 改图层
(vla-put-color a acbylayer) ; 颜色随层
)
)
)
(xyp-regen)
)
(xyp-initSet '(po1) '("0") )
(setq lst1 (xyp-get-layers)
ilst '(("po1" "图层" "poplist" "lst1" "8") "spacer;")
)
(if (= (xyp-Dcl-Init Ilst "【改块图层】" t) 1)
(main-pro)
)
(xyp-CMDLA1)
) xyp1964 发表于 2014-4-14 14:25 static/image/common/back.gif
仅供参考:
不是代码的代码, 本帖最后由 菜卷鱼 于 2014-4-15 12:59 编辑
http://lee-mac.com/applytoblockobjects.html
;; Apply to Block Objects-Lee Mac
;; Evaluates a supplied function on all objects in a block definition.
;; Arguments:
;; blks - VLA Block Collection in which block resides
;; name - Block name
;; func - function to apply to all objects in block
;; Returns a list of results of evaluating the function, else nil.
(defun LM:ApplytoBlockObjects ( blks name func / def result )
(setq func (eval func))
(if (not (vl-catch-all-error-p (setq def (vl-catch-all-apply 'vla-item (list blks name)))))
(vlax-for obj def (setq result (cons (func obj) result)))
)
(reverse result)
)
The following example program will move all objects in a block to Layer "0".
(defun c:test ( / s )
(princ "\nSelect Block: ")
(if (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
(LM:ApplytoBlockObjects
(vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
(vla-get-effectivename (vlax-ename->vla-object (ssname s 0)))
'(lambda ( obj ) (vla-put-layer obj "0"))
)
)
(princ)
)
(vl-load-com) (princ)
对多层嵌套块不完美
页:
[1]