ssget和动态块
你好我编写/修改了一个简单的lisp例程,用于重新插入选定的块。
它工作正常,但在尝试重新插入具有修改的可见性状态的动态块时遇到了问题。
我的问题是:
无论其可见性状态如何,是否可以按名称获取选定块?
以下是惯例:
(defun c:BLOCK-REINSERT ( / oldosmode blkname found pt1 )
(setq oldosmode (getvar "osmode"))
(if (and (setq blkname (cdr (assoc 2 (entget (car (entsel))))))
(setq found (ssget "x" (list (cons 2 blkname))))
(while
(setvar "osmode" oldosmode)
(setq pt1 (getpoint "\nSpecify placement point: "))
(setvar "osmode" 0)
(command "_.INSERT" blkname pt1 "1" "1" "0" "" "" ))
)
(cond ((not found)
(princ "\n Block not found in drawing !!!")))
)
(setvar "osmode" oldosmode)
(princ)
) 请参阅此函数。 谢谢你的提示,李!
我想我仍然不能很好地修改lisp例程。有什么帮助或提示吗?
(vl-load-com)
(defun c:test ( / oldosmode blkname pt1 )
(setq oldosmode (getvar "osmode"))
(setq blkname
(vlax-get-property obj
(if (vlax-property-available-p obj 'effectivename)
'effectivename
'name
)
)
)
(while
(setvar "osmode" oldosmode)
(setq pt1 (getpoint "\nSpecify placement point: "))
(setvar "osmode" 0)
(command "_.INSERT" blkname pt1 "1" "1" "0" "" "" ))
)
(cond ((not found)
(princ "\n Block not found in drawing !!!")
)
)
(setvar "osmode" oldosmode)
(princ)
)
无需从我的函数中提取代码,只需从程序中调用函数,例如:
(defun c:block-reinsert ( / att blk sel )
(if (setq sel (ssget "_+.:E:S" '((0 . "INSERT"))))
(progn
(setq blk (LM:al-effectivename (ssname sel 0))
att (getvar 'attreq)
)
(setvar 'attreq 0)
(while (vl-cmdf "_.-insert" blk "_S" 1.0 "_R" 0.0 "\\"))
(setvar 'attreq att)
)
)
(princ)
)
;; Effective Block Name-Lee Mac
;; ent - Block Reference entity
(defun LM:al-effectivename ( ent / blk rep )
(if (wcmatch (setq blk (cdr (assoc 2 (entget ent)))) "`**")
(if
(and
(setq rep
(cdadr
(assoc -3
(entget
(cdr
(assoc 330
(entget
(tblobjname "block" blk)
)
)
)
'("AcDbBlockRepBTag")
)
)
)
)
(setq rep (handent (cdr (assoc 1005 rep))))
)
(setq blk (cdr (assoc 2 (entget rep))))
)
)
blk
)
注意,您也可以使用ADDSELECTED命令。 或者只是复制块。 谢谢李,现在我(也许还有其他人)将知道如何使用you'r网站上那些有用的功能!
iconeo:对不起,我是专门找重新插入的。 不客气! 我刚刚测试过,它很有魅力。
唯一的问题是退出while循环-我必须按住ESC键才能断开循环。
是的,这就是在-INSERT命令中使用暂停等待用户输入的缺点-无法控制接收到的输入。
另一种方法是事先获得点,但牺牲了插入预览:
(defun c:block-reinsert ( / att blk ins sel )
(if (setq sel (ssget "_+.:E:S" '((0 . "INSERT"))))
(progn
(setq blk (LM:al-effectivename (ssname sel 0))
att (getvar 'attreq)
)
(setvar 'attreq 0)
(while (setq ins (getpoint "\nSpecify insertion point <exit>: "))
(command "_.-insert" blk "_S" 1.0 "_R" 0.0 "_non" ins)
)
(setvar 'attreq att)
)
)
(princ)
)
;; Effective Block Name-Lee Mac
;; ent - Block Reference entity
(defun LM:al-effectivename ( ent / blk rep )
(if (wcmatch (setq blk (cdr (assoc 2 (entget ent)))) "`**")
(if
(and
(setq rep
(cdadr
(assoc -3
(entget
(cdr
(assoc 330
(entget
(tblobjname "block" blk)
)
)
)
'("AcDbBlockRepBTag")
)
)
)
)
(setq rep (handent (cdr (assoc 1005 rep))))
)
(setq blk (cdr (assoc 2 (entget rep))))
)
)
blk
)
但是,请注意按ESC退出提示,因为如果没有错误处理程序,ATTREQ sys var将不会重置。 我尝试了两种程序,没有预览就有点糟糕(我并不总是需要它)。
通过调用“基点”选项,然后按ESC键,找到了一种更容易打破循环的方法。
谢谢你花时间,李!
页:
[1]