- (defun c:wzpx (/ e1 e2 ent heigh heighy i inpoint k lst ob ob_ptx ob_pty pt
- pto ptx ss
- )
- (prompt "\n欢迎使用由Gavin业余时间写的程序! 本程序命令:wzpx")
- (prompt "\n本程序主要功能:将文字左对齐并按一定间距排序!")
- (setq ss (ssget '((0 . "text"))))
- (setq i 0
- lst '()
- )
- (repeat (sslength ss)
- (setq ent (ssname ss i))
- (setq inpoint (Vlax-Get (Vlax-Ename->Vla-Object ent) 'InsertionPoint))
- (setq lst (append
- (list (cons ent inpoint))
- lst
- )
- )
- (setq i (1+ i))
- )
- (setq lst (vl-sort lst (function (lambda (e1 e2)
- (< (caddr e1) (caddr e2))
- )
- )
- )
- )
- (setq ob_ptx (cadr (last lst)))
- (setq ob_pty (caddr (last lst)))
- (setq heigh (Vlax-Get (Vlax-Ename->Vla-Object (car (last lst))) 'Height))
- (setq k 0)
- (repeat (length lst)
- (setq ob (Vlax-Ename->Vla-Object (car (nth k lst))))
- (setq pt (Vlax-Get ob 'InsertionPoint))
- (setq ptx (subst
- ob_ptx
- (car pt)
- pt
- )
- )
- (setq heighy (- ob_pty (* 1.2 heigh (- (length lst) (1+ k)))))
- (setq pto (subst
- heighy
- (cadr ptx)
- ptx
- )
- )
- (Vlax-Put-Property ob 'InsertionPoint (Vlax-3d-Point pto))
- (Vlax-Put-Property ob 'Height heigh)
- (setq k (1+ k))
- )
- (princ)
- )
|