乐筑天下

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

[编程交流] Un-dynamic a block - LISP

[复制链接]

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 17:40:12 | 显示全部楼层
@Lee: Thanks for your comments. I'll send a Support Request to the Bricsys team.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:46:34 | 显示全部楼层
You're welcome Roy.
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 17:48:51 | 显示全部楼层
I've followed the steps Roy mentioned on my Acad 2015, and can comfirm this:
Seems that it adds new block definition, under the provided name:
  1. (vla-ConvertToStaticBlock o "ABC")
But, when I try to convert other block reference under the same / existing block definition name, I get:
  1. _$ (vla-ConvertToStaticBlock o "ABC")Error: Automation Error. Duplicate key_1$
But/And It creates an annonymous block definition anyway:
  1. _$ (vla-get-EffectiveName (vlax-ename->vla-object (car (entsel))))"*U117"_$
180233dxleo74z4d5tleld.jpg
Note that the "Name" property row in the quick properties dialog, always references to the block's "effective name / definition name".
 
So thats why my previously posted code forces the creation of N annonymous block definitions:
  1. (ErrCatcher 'vla-ConvertToStaticBlock (list o (vla-get-EffectiveName o)))
Since this always triggers an error
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:51:45 | 显示全部楼层
 
Of course: the block name argument for the ActiveX converttostaticblock method cannot correspond to an existing block, otherwise you will receive a duplicate key error - this is why the original code included the '_make_key' function.
回复

使用道具 举报

7

主题

26

帖子

19

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 17:57:15 | 显示全部楼层
First of all, thanks for all the help so far!
I would like to think together with you guys, but since I can't program, it's though
 
Let me know if you find a solution please!
Thanks!
- Martin
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 18:00:42 | 显示全部楼层
 
Try this:
  1. (defun C:test ( / ErrCatcher BlksColl SS i o cnt flg nm ); (ErrCatcher 'vla-item (list (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) "BlockThatDoesNotExist")) -> nil(defun ErrCatcher ( func varLst / rtn ) (if (not (vl-catch-all-error-p (setq rtn (vl-catch-all-apply func varLst)))) rtn))(setq BlksColl (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))))(prompt "\nSelect blocks to convert them into static ones:" )(if (setq SS (ssget "_:L" (list (cons 0 "INSERT"))))        (repeat (setq i (sslength SS))                (if (eq :vlax-true (vla-get-IsDynamicBlock (setq o (vlax-ename->vla-object (ssname SS (setq i (1- i)))))))                        (progn                                (setq cnt 0) (setq flg 'T)                                (while flg                                        (if (not (ErrCatcher 'vla-item (list BlksColl (setq nm (strcat (vla-get-EffectiveName o) "_" (itoa (setq cnt (1+ cnt))))))))                                                (progn (vla-ConvertToStaticBlock o nm) (setq flg nil))                                        ); if                                ); while                        ); progn                ); if        ); repeat); if(princ));| defun |; (or vlax-get-acad-object (vl-load-com)) (princ)
Note that the original dynamic blocks are not purged.
回复

使用道具 举报

7

主题

26

帖子

19

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 18:04:40 | 显示全部楼层
 
Super! This is what I was looking for!
Thank you so much!
-Martin
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 02:11 , Processed in 4.266163 second(s), 67 queries .

© 2020-2025 乐筑天下

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