- (defun c:js (/ BZ SS P YLST LST N EN ENBOX P1 P9 Y TUYUAN I YYLST EE P11)
- (setvar "cmdecho" 0)
- (command "undo" "be")
- (setq bz(getvar "osmode"))(setvar "osmode" 0)
- (setq ss(ssget))
- (setq p(getpoint "\n选择排列起始点:"))
- (setq ylst '() lst '())
- (repeat(setq n(sslength ss))
- (setq en(ssname ss(setq n(1- n))))
- (setq enbox(getenbox en))
- (setq p1(car enbox))
- (setq p9(cadr enbox))
- (setq y(-(cadr p9)(cadr p1)));---获取单个图元的Y长度
- (setq tuyuan(cdr(assoc -1(entget en))));---获取图元名
- (setq lst(cons(list y tuyuan )lst))
-
- )
- (setq lst (vl-sort lst
- (function (lambda (e1 e2)
- (<(car e1) (car e2))
- )
- )
- )
- I 0
- )
- (repeat (length LST)
- (setq yylst(nth I lst));---返回yy对应的那个
- (setq EE(cadr yylst))
- (setq enbox(getenbox EE))
- (setq p11(car enbox))
- (vla-move (vlax-ename->vla-object EE) (vlax-3D-point p11 ) (vlax-3D-point p ))
- (setq enbox(getenbox EE))
- (setq p(list(car(cadr enbox))(cadr P)))
- (setq I(1+ I))
- )
- (setvar "osmode" bz)
- (command "undo" "e")
- (setvar "cmdecho" 1)
- (princ)
- )
- ;---返回a在表lst中的位置
- ;;;(defun lstwz(a lst / b)
- ;;; (cond((setq b(member a lst))(-(length lst)(length b))))
- ;;;)
- ;---获取单个图元左下角,右上角,中心点坐标
- (defun getenbox(en / enbox py pz pzx)
- (vla-getboundingbox(vlax-ename->vla-object en) 'minp 'maxp)
- (setq pz(vlax-safearray->list minp))
- (setq py(vlax-safearray->list maxp))
- (setq pzx(mapcar '(lambda(X Y)(/(+ X Y)2))pz py))
- (setq enbox(list pz py pzx))
- enbox
- )
不知道是不是你想要的 |