乐筑天下

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

[编程交流] Routine to set transparency &#

[复制链接]

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 17:05:38 | 显示全部楼层
Hans if you want to change the block definitions for a selection of block references you should first extract their block names:
  1. ; (NestedPutProp "MyBlk" 'entitytransparency "BYBLOCK"); (NestedPutProp "MyBlk" 'color 3)(defun NestedPutProp (nme prop val / blk) (if   (and     (not       (vl-catch-all-error-p          (setq blk           (vl-catch-all-apply             'vla-item             (list               (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))               nme             )           )         )       )     )     (= :vlax-false (vla-get-islayout blk))     (= :vlax-false (vla-get-isxref blk))   )   (vlax-for obj blk (vlax-put obj prop val)) ))(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret) (if ss   (repeat (setq i (sslength ss))     (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret))   ) ))(defun C:TRBB ( / doc doneLst ss) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (if (setq ss (ssget '((0 . "INSERT"))))   (foreach obj  (KGA_Conv_Pickset_To_ObjectList ss)     (if (not (vl-position (strcase (vla-get-name obj)) doneLst))       (progn         (NestedPutProp (vla-get-name obj) 'entitytransparency "BYBLOCK")         (setq doneLst (cons (strcase (vla-get-name obj))))       )     )   ) ) (vla-endundomark doc) (princ))
回复

使用道具 举报

37

主题

264

帖子

236

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
185
发表于 2022-7-5 17:08:41 | 显示全部楼层
Thx !! that was what i was assuming...
This piece of code allready saves me a whole bunch of dead work load!
But it is still picking blocks one-by-one..
 
The final touch would be it would work on a sessies of blocks for ssget.
As reference, this tool from Gile that can do allmost all, except for the tranparency.
 
http://gilecad.azurewebsites.net/LISP/Edit_bloc_3.5.zip
 
 

172335ey4t1oftbyzyr4no.jpg
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 17:14:03 | 显示全部楼层
Judging from your last comment you have not tested the code in my previous post. If you analyse the code you will notice:
  1. (setq ss (ssget '((0 . "INSERT"))))
回复

使用道具 举报

37

主题

264

帖子

236

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
185
发表于 2022-7-5 17:17:29 | 显示全部楼层
I did however, just does not work as that way.
Only 1 block is redined. Check the link.
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 17:19:58 | 显示全部楼层
OK try this:
  1. ; (NestedPutProp "MyBlk" 'entitytransparency "BYBLOCK"); (NestedPutProp "MyBlk" 'color 3)(defun NestedPutProp (nme prop val / blk) (if   (and     (not       (vl-catch-all-error-p         (setq blk           (vl-catch-all-apply             'vla-item             (list               (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))               nme             )           )         )       )     )     (= :vlax-false (vla-get-islayout blk))     (= :vlax-false (vla-get-isxref blk))   )   (vlax-for obj blk (vlax-put obj prop val)) ))(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret) (if ss   (repeat (setq i (sslength ss))     (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret))   ) ))(defun C:TRBB ( / doc doneLst ss) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (if (setq ss (ssget '((0 . "INSERT"))))   (foreach obj  (KGA_Conv_Pickset_To_ObjectList ss)     (if (not (vl-position (strcase (vla-get-name obj)) doneLst))       (progn         (NestedPutProp (vla-get-name obj) 'entitytransparency "BYBLOCK")         (setq doneLst (cons (strcase (vla-get-name obj)) doneLst))       )     )   ) ) (vla-regen doc acactiveviewport) (vla-endundomark doc) (princ))
回复

使用道具 举报

37

主题

264

帖子

236

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
185
发表于 2022-7-5 17:24:26 | 显示全部楼层
Great !!!
Many thanks!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-1 15:07 , Processed in 0.529747 second(s), 64 queries .

© 2020-2025 乐筑天下

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