尘缘一生 发表于 2017-8-11 16:43:24

求:若不存在,则插入图块,若存在则忽略代码

如题,若图纸中存在,XYZ图块的话,则忽略,若还没有,则插入他。


求段代码。。。。

fan_zh 发表于 2017-8-11 17:14:35

tblsearch      

ll_j 发表于 2017-8-11 17:17:39

使用tblobjname或tbjsearch检索块是否存在。

尘缘一生 发表于 2017-8-11 18:53:47

我这么作成功了,

(if (null (ssget "x" (list (cons 0 "insert")(cons 2 "dimblk"))))
        (progn   
      (setq pt1 (nth 1(grread 5)))
        (command "insert" "dm-blk" pt1 "" "" "")
        (command "erase" "l" "")
        (command "dim" "dimblk" "dimblk" "exit"))
)

xyp1964 发表于 2017-8-11 22:09:04

(while (setq d (tblnext "block" (null d)))
(setq lst (cons (cdr (assoc 2 d)) lst))
)
(if (and (not (member "XYZ" lst)) (setq a (findfile "xyz.dwg")))
(command "insert" a '(0 0) "" "" "")
)
页: [1]
查看完整版本: 求:若不存在,则插入图块,若存在则忽略代码