本帖最后由 zhb236623 于 2013-7-31 18:33 编辑
如图,或者下载CAD图里面有我想要达到的效果……想要把数字批量替换,然后数字递增,批量替换数字的时候按从左到右,从上到下的顺序替换……。应该用得着下面的程序,但是自己能力有限,写不出来。盼高手赐教。 ;;;;取得点集行数,将每行的y坐标列表,lst为点坐标表,rc为容差
- (defun y_lst (lst rc / it lst2)
- (while (setq lst2 (cons (setq it (cadr (car lst))) lst2)
- lst (vl-remove-if '(lambda (x) (equal it (cadr x) rc)) lst)
- )
- )
- (vl-sort lst2 (function (lambda (e1 e2) (> e1 e2))))
- )
- ;;;将点集按从上到下,从左到右的顺序排序。pt_lst为点坐标表,rc为容差
- (defun dh_zhy_sort_pt (pt_lst rc / pt_y lst1 pt_lst_new n1 n2 m1 m2 pt_y_a pt_lst_a lst2)
- (setq pt_y (y_lst pt_lst rc))
- (setq pt_lst_new '())
- (setq lst1 '())
- (setq m1 0)
- (setq n1 (length pt_y))
- (setq n2 (length pt_lst))
- (while (/= m1 n1)
- (setq pt_y_a (nth m1 pt_y))
- (setq m2 0)
- (while (/= m2 n2)
- (setq pt_lst_a (nth m2 pt_lst))
- (if (equal pt_y_a (cadr pt_lst_a) rc)
- (setq lst1 (cons pt_lst_a lst1))
- )
- (setq m2 (1+ m2))
- )
- (if (/= (length lst1) 1)
- (setq lst1 (vl-sort lst1
- (function (lambda (e1 e2) (< (car e1) (car e2))))
- )
- )
- )
- (setq pt_lst_new (cons lst1 pt_lst_new))
- (setq lst1 '())
- (setq m1 (1+ m1))
- )
- (setq pt_lst_new (reverse pt_lst_new))
- (setq n1 (length pt_lst_new))
- (setq m1 0)
- (setq lst2 '())
- (while (/= m1 n1)
- (setq lst1 (nth m1 pt_lst_new))
- (setq n2 (length lst1))
- (setq m2 0)
- (while (/= m2 n2)
- (setq lst (nth m2 lst1))
- (setq lst2 (cons lst lst2))
- (setq m2 (1+ m2))
- )
- (setq m1 (1+ m1))
- )
- (reverse lst2)
- )
|