SunnyTurtle 发表于 2022-7-6 06:57:37

动态块和脚本

嗨,我试图创建一个脚本,将删除所有类型的动态块。我可以使用快速选择和按名称筛选来完成本手册。
但是我不能用我在脚本中使用的ssx命令来实现这一点
 
所以我想我有两个问题:
[列表=1]
[*]您可以在脚本中使用quickselect吗?
[*]quickselect如何按名称确定这些块?
[/列表]

YZ 发表于 2022-7-6 07:10:40

您可以在脚本中使用QSELECT命令,但它会弹出一个对话框。
 
由于某些原因,该命令没有-QSELECT替代选项来将其抑制到命令行。因此,很难为其自动生成脚本。
 
这个论坛上有人之前建议我尝试使用过滤器,但我还没有时间验证它是否有效。

SunnyTurtle 发表于 2022-7-6 07:19:07

嗨YZ
我已经找到了解决问题的方法,但遗憾的是,没有办法自动进行QSELECT或筛选。
为了删除所有的实际动态块,我混合使用了lisp和script。
 
Lisp DDSS(动态块选择集)
;SORCED http://forums.augi.com/archive/index.php/t-31578.html
;17/11/2011
;posted by irneb ;at 2007-12-07, 01:11 PM ;on http://forums.augi.com/archive/index.php/t-31578.html
;modified RCondon 17/11/2011

(defun c:DBSS (/ name ss namelist n en ed eo sslist)
;; Ask user for block's effective name
(if (not (setq name (getstring "Enter the block's effective name: ")))
(quit)
) ;_ end of if
;; Search through blocks for anonymous referring to this effective name
(setq namelist (list name) ;Initialize names list with normal block's name
ss (ssget "x" '((0 . "INSERT") (2 . "`**"))) ;Get all anonymous blocks in drawing
n 0 ;Initialize counter
) ;_ end of setq
;; Step through selection set
(while (< n (sslength ss))
;; Get nth entity in selection set + it's data
(setq en (ssname ss n)
ed (entget en)
) ;_ end of setq
;; Check if it isn't an unchanged dynamic block & that it hasn't been added to the list already
(if (and
(/= name (cdr (assoc 2 ed)))
(not (member (strcat "`" (cdr (assoc 2 ed))) namelist))
) ;_ end of and
(progn
;; Get the entity's object handle
(setq eo (vlax-ename->vla-object en))
;; Check if effective name is the same
(if (= name (vlax-get-property eo 'EffectiveName))
;; Add the anonymous block's name with reverse appostrophe prefix
(setq namelist (cons (strcat "`" (cdr (assoc 2 ed))) namelist))
) ;_ end of if
) ;_ end of progn
) ;_ end of if
(setq n (1+ n))
) ;_ end of while
;; Clear selection set & clear memory
(setq ss nil)
(gc)
;; Construct the selection filter list in reverse order
(setq sslist '((-4 . "<OR") (0 . "INSERT"))
n 0
) ;_ end of setq
;; Step through the list of names
(while (< n (length namelist))
;; Add the name to the filter list
(setq sslist (cons (vl-list* 2 (nth n namelist)) sslist))
(setq n (1+ n))
) ;_ end of while
;; End the filter list's OR section
(setq sslist (cons '(-4 . "OR>") sslist))
;; Reverse the list to get it in the correct order
(setq sslist (reverse sslist))
) ;_ end of defun
运行lisp所需的脚本
(load "DBSS.lsp")
DBSS
TAG_PAV
_.erase P

SunnyTurtle 发表于 2022-7-6 07:31:49

我最近升级到2012年,这个lisp不起作用
它选择所有块,而不是过滤,而是名称。
 
有人能帮我修改吗

YZ 发表于 2022-7-6 07:36:27

既然您使用的是lisp而不是脚本,那么在lisp论坛中可能会更好。

SunnyTurtle 发表于 2022-7-6 07:42:10

有没有办法移动这个帖子,或者我需要发布一个新的帖子

YZ 发表于 2022-7-6 07:56:49

我不知道如何移动它。我经常看到主持人代表我们这样做。但如果你没有收到任何消息,那么我会说复制并粘贴到该论坛的新帖子中。

SLW210 发表于 2022-7-6 07:58:19

将您的线程重新定位到AutoLISP、Visual LISP和DCL论坛。
页: [1]
查看完整版本: 动态块和脚本