?? 選擇集中點lisp.lsp
字號:
(Defun C:test (/ ss)
(VL-LOAD-COM)
;; get the selection set .
(princ "\nPlease select object:")
(setq ss (vl-catch-all-apply 'ssget))
(if (or (vl-catch-all-error-p ss) (null ss))
(vl-exit-with-value 0)
)
;; get the Middle point from the selection set .
(setq pt (GetMidPt ss))
(if pt
(foreach n (list "\nThe Middle Point X=" (car pt) " Y=" (cadr pt)) (princ n))
(princ "\n There is error , can't get the middle point...")
)
(prin1)
)
;; the sub function to get the middle point from the selection set .
(defun GetMidPt (ss / i lstX lstY vn pt X1 X2 Y1 Y2)
(setq i 0
lstX '()
lstY '()
)
(repeat (sslength ss)
(setq vn (vlax-ename->vla-object (ssname ss i))
i (1+ i)
)
(setq pt (vl-catch-all-apply 'vla-getBoundingBox (list vn 'MinPt 'MaxPt)))
(if (not (vl-catch-all-error-p pt))
(progn
(setq X1 (vlax-safeArray-get-element MinPt 0)
X2 (vlax-safeArray-get-element MaxPt 0)
Y1 (vlax-safeArray-get-element MinPt 1)
Y2 (vlax-safeArray-get-element MaxPt 1)
)
(cond
;; if this is the first time run,then put the value it .
((null lstX)
(setq lstX (list X1 X2)
lstY (list Y1 Y2)
)
)
;; NOTE here, .
(T
;; X-Min .
(if (< X1 (car lstX))
(setq lstX (list X1 (cadr lstX)))
)
;; X-Max
(if (> X2 (cadr lstX))
(setq lstX (list (car lstX) X2))
)
;; Y-Min .
(if (< Y1 (car lstY))
(setq lstY (list Y1 (cadr lstY)))
)
;; Y-Max
(if (> Y2 (cadr lstY))
(setq lstY (list (car lstY) Y2))
)
)
)
)
)
)
;; return the point .
(if lstX
(list (* (apply '+ lstX) 0.5) (* (apply '+ lstY) 0.5))
nil
)
)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -