本帖最后由 xyp1964 于 2017-11-20 21:53 编辑
- ;; xyp-SsSort-Dxf 选择集依据dxf码值分类 (xyp-SsSort-Dxf ss mode)
- ;; (xyp-SsSort-Dxf (ssget) 1)
- (defun xyp-SsSort-Dxf (ss mode / lst-dxf i s1 lst-num a b lst dx)
- (if (and ss (= (type ss) 'PICKSET) (> (sslength ss) 0))
- (progn
- (setq lst-dxf '()
- i -1
- )
- (while (setq s1 (ssname ss (setq i (1+ i))))
- (setq dx (xyp-dxf mode s1)
- lst-dxf (cons (list dx s1) lst-dxf)
- )
- )
- (setq lst-dxf (vl-sort lst-dxf '(lambda (x y) (< (car x) (car y))))
- lst-num '()
- a (car lst-dxf)
- lst-dxf (cdr lst-dxf)
- lst (list (cadr a))
- )
- (while (setq b (car lst-dxf))
- (setq lst-dxf (cdr lst-dxf))
- (if (= (type (car a)) 'REAL)
- (if (equal (car a) (car b) 1e-5)
- (setq lst (cons (cadr b) lst))
- (setq lst-num (cons (list (car a) (reverse lst)) lst-num)
- lst (list (cadr b))
- a b
- )
- )
- (if (equal (car a) (car b))
- (setq lst (cons (cadr b) lst))
- (setq lst-num (cons (list (car a) (reverse lst)) lst-num)
- lst (list (cadr b))
- a b
- )
- )
- )
- )
- (reverse (cons (list (car a) (reverse lst)) lst-num))
- )
- )
- )
|