我建议将选择操作划分为一个单独的功能,例如:
- (defun c:test ( / des prd src )
- (setq prd
- '(lambda ( x )
- (wcmatch
- (cdr (assoc 0 (entget x)))
- "LINE,ARC,CIRCLE,LWPOLYLINE,POLYLINE,RAY,XLINE,AECC_FEATURE_LINE"
- )
- )
- )
- (if
- (and
- (setq src (selectif "\nSelect source object: " prd))
- (setq des (selectif "\nSelect destination object: " prd))
- )
- (princ "\nDo stuff.")
- )
- (princ)
- )
- (defun selectif ( msg prd / ent )
- (while
- (progn (setq ent (car (entsel msg)))
- (cond
- ( (= 7 (getvar 'errno))
- (princ "\nMissed, try again.")
- )
- ( (not ent) nil)
- ( (not (apply prd (list ent)))
- (princ "\nInvalid object selected.")
- )
- )
- )
- )
- ent
- )
|