本帖最后由 菜卷鱼 于 2024-8-3 08:44 编辑
以下举例是同名块的更换,假如块名不同,你要改一下代码
先把A块Wblock写出到搜索路径,再运行UP程序
假如是属性块,更新完之后,记得attsync一下
核心代码其实就一句,就是 (command "-insert" (strcat eff "=" eff ".dwg"))
意思是 (command "-insert" "图块A名 = 图块B名.dwg" )
- (defun en-effname (ent)
- (LM:al-effectivename ent)
- )
- (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
- )
- (defun c:up (/ ss obj eff nl i)
- (setq ss (ssget '((0 . "insert"))))
- ;;;(undobe)
- (setq i 0)
- (repeat (sslength ss)
- (setq obj (ssname ss i))
- (setq i (1+ i))
- (setq eff (en-effname obj))
- (if (and eff (not (member eff nl)))
- (progn
- (setq nl (cons eff nl))
- (command "-insert" (strcat eff "=" eff ".dwg"))
- (command)
- ;;;(prinx "\n更新:" eff)
- )
- )
- )
- ;;; (undo_e)
- (princ "\n完成")
- (prin1)
- )
|