本帖最后由 xiaocainiao 于 2024-2-16 08:44 编辑
请教一下各位大神、下面是我弄的一个修改图块颜色的代码、现在有一个问题:
就是用blk_col_change修改后、需要用-bedit命令进入块编辑器并保存退出、
对应的同名块才能在屏幕上更新显示、
我想问一下有没有办法不用-bedit命令、直接更新修改后的同名块?
之前试过用vla-Update更新、但是这个函数貌似只能更新单个图元、如果图块是嵌套在其他块里、就不好处理了、
另外楼下有大神分享了程序可以更新同名块、但是将普通块和动态块分开处理了、我想统一处理不知道能否实现?
- (defun c:tt (/ blk_col_change blk_name blks block_bh_col_new en obj ss)
- ;修改块内图元颜色
- (defun blk_col_change (blk block_bh_col_new)
- (vlax-for x blk
- (vla-put-Color x block_bh_col_new)
- (if (= "INSERT" (cdr (assoc 0 (entget (vlax-vla-object->ename x)))))
- (blk_col_change (vla-Item blks (vla-get-EffectiveName x)) block_bh_col_new)
- )
- )
- )
- (setq blks (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))))
- (setq ss (ssget ":S"'((0 . "insert"))))
- (if ss
- (progn
- (setq en (ssname ss 0))
- (setq obj (vlax-ename->vla-object en)
- blk_name (vla-get-EffectiveName obj)
- )
- (setq block_bh_col_new (getint "\n输入新的色号:<250>"))
- (if (null block_bh_col_new)(setq block_bh_col_new 250))
- (blk_col_change (vla-Item blks blk_name) block_bh_col_new)
- (command "-bedit" blk_name)
- (command "bsave")
- (command "bclose")
- )
- )
- )
测试文件上传到附件了、如果有会的朋友、感谢解答
|