如果我理解正确(未经测试):
- (defun c:l2b (/ lst)
- (if (and (AT:GetSel entsel "\nSelect first block: " (lambda (x / d) (if (eq (cdr (assoc 0 (setq d (entget (car x))))) "INSERT")
- (setq lst (list (assoc 10 d) (assoc 210 d)))
- )
- )
- )
- (AT:GetSel entsel "\nSelect second block: " (lambda (x / d) (if (eq (cdr (assoc 0 (setq d (entget (car x))))) "INSERT")
- (setq lst (cons (assoc 10 d) lst))
- )
- )
- )
- )
- (entmakex (append '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (100 . "AcDbPolyline") (90 . 2)) lst))
- )
- (princ)
- )
- (defun AT:GetSel (meth msg fnc / ent)
- ;; meth - selection method (entsel, nentsel, nentselp)
- ;; msg - message to display (nil for default)
- ;; fnc - optional function to apply to selected object
- ;; Ex: (AT:GetSel entsel "\nSelect arc: " (lambda (x) (eq (cdr (assoc 0 (entget (car x)))) "ARC")))
- ;; Alan J. Thompson, 05.25.10
- (while
- (progn (setvar 'ERRNO 0)
- (setq ent (meth (cond (msg)
- ("\nSelect object: ")
- )
- )
- )
- (cond ((eq (getvar 'ERRNO) 7) (princ "\nMissed, try again."))
- ((eq (type (car ent)) 'ENAME)
- (if (and fnc (not (fnc ent)))
- (princ "\nInvalid object!")
- )
- )
- )
- )
- )
- ent
- )
伙计,用记事本编码,没有格式化,真是糟透了。我简直不敢相信我学会了这样编码。 |