本帖最后由 kanxiaokan 于 2019-7-24 15:27 编辑
我需要得到如图所示的效果,如何修改下面的代码?
- (defun c:tt ()
- (princ "\n请选择要排序的实体...")
- (if (setq ss (ssget))
- (progn
- ;; 1、获取点位表
- (setq lst '()
- i 0
- )
- (repeat (sslength ss)
- (setq en (ssname ss i)
- ent (entget en)
- pt (cdr (assoc 10 ent))
- lst (cons pt lst)
- i (1+ i)
- )
- )
- ;; 2、排序
- (setq
- lst (vl-sort lst '(lambda (e1 e2)
- (if (equal (car e1) (car e2) 1e1)
- (if (equal (cadr e1) (cadr e2) 1e1)
- (< (car e1) (car e2))
- (< (cadr e1) (cadr e2))
- )
- (< (car e1) (car e2))
- )
- )
- )
- )
- ;; 3、写序号文字
- (setq i 1)
- (foreach pt lst
- (command "_.text" "j" "mc" "non"pt (getvar "TEXTSIZE") 0 (itoa i))
- (setq i (1+ i))
- )
- )
- )
- (princ)
- )
|