undo代码你自己去写一下
- (defun c:xx (/ s i res)
- (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
- (undobe)
- (setq i 0)
- (setq res (xpinside s))
- (if (= (member "on" res) nil)
- (princ "\n对象内不含嵌套块")
- (PROGN
- (while
- (member "on" res)
- (setq res (xpinside s))
- )
- (princ "\n已分解嵌套块"))
- )
- (setq i nil)
- (undoe)
- (prin1)
- )
- (defun xpinside (s / lock)
- (setq lock "off")
- (LM:ApplytoBlockObjects
- (vla-get-blocks
- (vla-get-activedocument (vlax-get-acad-object)))
- (vla-get-effectivename
- (vlax-ename->vla-object (ssname s 0)))
- '(lambda (obj)
- (if
- (= (vla-get-ObjectName obj) "AcDbBlockReference")
- (PROGN (vla-explode obj) (vla-delete obj) (setq lock "on"))
- )
- )
- )
- )
- (defun LM:ApplytoBlockObjects (blks name func / result)
- (setq func (eval func))
- (if
- (not
- (vl-catch-all-error-p
- (setq def (vl-catch-all-apply 'vla-item (list blks name)))
- )
- )
- (vlax-for obj def (setq result (cons (func obj) result)))
- )
- (reverse result)
- )
|