本帖最后由 kozmosovia 于 2025-8-7 11:06 编辑
你现在的代码根本没有处理块内图形。
新写了一个,最后不需要复制了再删除,直接用移动才好。
块会自动被分解到底。
没有测试
 - (defun c:sx (/ _copy chklay *ERROR*_BAK IDX OBJ SS SSX T-*ERROR*)
- (defun T-*error* (msg)
- (and ssx (vl-cmdf "_.erase" ssx "")) ;删除图元
- (setq *error* *error*_bak)
- (princ)
- )
- (defun chklay (layname col /)
- (if (null (tblsearch "layer" layname))
- (vl-cmdf "-layer" "n" layname "c" col layname "")
- )
- )
- (Defun _copy (ss / IDX OBJ RTN)
- (setq idx -1)
- (repeat (sslength ss)
- (and (setq obj (vl-remove-if
- (function
- (lambda (x)
- (member (car x) (list -1 5 62 420 421))
- )
- )
- (entget (ssname ss (setq idx (1+ idx))))
- )
- obj (entmakex (subst (cons 8 "020划线") (assoc 8 obj) obj))
- )
- (if (= (cdr (assoc 0 (entget obj))) "INSERT")
- (setq obj (vl-cmdf "_.explode" obj)
- rtn (append rtn (_copy (ssget "_p")))
- )
- (setq rtn (cons obj rtn))
- )
- )
- )
- rtn
- )
- (setq *error*_bak
- *error*
- *error* T-*error*
- )
- (chklay "020划线" "250")
- (and (setq ss (ssget))
- (setq ss (_Copy ss))
- (setq ssx (ssadd))
- (progn (foreach abc ss (ssadd abc ssx))
- (vl-cmdf "_.Move" ssx "" pause pause "") ;复制
- )
- )
- (princ)
- )
|