本帖最后由 q3_2006 于 2014-4-11 15:05 编辑
来个好理解的版本.... - (defun ebox (e / pa pb)
- (Vlax-Invoke-Method (Vlax-Ename->Vla-Object e ) 'GetBoundingBox 'pa 'pb )
- (setq pa (trans (vlax-safearray->list pa) 0 1)
- pb (trans (vlax-safearray->list pb) 0 1)
- )
- (list pa pb)
- )
- (defun mid (p1 p2) (mapcar '* '(0.5 0.5 0.5) (mapcar '+ p1 p2)))
- (defun c:tt ( / box d e h n p p1 p2 pc w)
- (setvar "osmode" 2)
- (while (setq p (getpoint "\n以点取边为阵列方向:"))
- (setq e (ssname (ssget "c" p p '((0 . "LWPOLYLINE"))) 0)
- n (getint "\n数量:")
- d (getdist "\n间距:")
- box (ebox e)
- p1 (car box)
- p2 (cadr box)
- pc (mid p1 p2)
- )
- (mapcar 'set '(w h) (mapcar '- p2 p1))
- (cond
- ((and (> (car p) (car pc)) (equal (cadr p) (cadr pc))) (vl-cmdf "-array" e "" "r" 1 n (+ d w)))
- ((and (< (car p) (car pc)) (equal (cadr p) (cadr pc))) (vl-cmdf "-array" e "" "r" 1 n (* -1 (+ d w))))
- ((and (equal (car p) (car pc)) (> (cadr p) (cadr pc))) (vl-cmdf "-array" e "" "r" n 1 (+ d h)))
- (t (vl-cmdf "-array" e "" "r" n 1 (* -1 (+ d h))))
- )
- )
- )
|