本帖最后由 xyp1964 于 2024-8-23 15:11 编辑
- ;; xyp-9Pt 实体或选择集9点坐标 (xyp-9Pt ename site)
- (defun xyp-9Pt (ename site / MinPT MaxPT p1 p9 p5 p3 p7 p2 p4 p6 p8 i p1a p9a s1 x ob mid)
- (defun mid (p1 p2)
- (mapcar '(lambda (x) (* x 0.5)) (mapcar '+ p1 p2))
- )
- (cond ((= (type ename) 'ENAME)
- (vla-getboundingbox (vlax-ename->vla-object ename) 'MinPT 'MaxPT)
- (setq p1 (vlax-safearray->list MinPT)
- p9 (vlax-safearray->list MaxPT)
- )
- )
- ((= (type ename) 'VLA-OBJECT)
- (vla-getboundingbox ename 'MinPT 'MaxPT)
- (setq p1 (vlax-safearray->list MinPT)
- p9 (vlax-safearray->list MaxPT)
- )
- )
- ((= (type ename) 'PICKSET)
- (setq i -1
- p1a '()
- p9a '()
- )
- (while (setq s1 (ssname ename (setq i (1+ i))))
- (setq ob (vlax-ename->vla-object s1))
- (vla-getboundingbox ob 'MinPT 'MaxPT)
- (setq p1 (vlax-safearray->list MinPT)
- p9 (vlax-safearray->list MaxPT)
- p1a (cons p1 p1a)
- p9a (cons p9 p9a)
- )
- )
- (setq p1 (apply 'mapcar (cons 'min p1a))
- p9 (apply 'mapcar (cons 'max p9a))
- )
- )
- )
- (setq p5 (mid p1 p9)
- p3 (if (< (car p9) (car p1))
- (list (car p1) (cadr p9) (caddr p1))
- (list (car p9) (cadr p1) (caddr p1))
- )
- p7 (if (< (car p9) (car p1))
- (list (car p9) (cadr p1) (caddr p9))
- (list (car p1) (cadr p9) (caddr p9))
- )
- p2 (mid p1 p3)
- p4 (mid p1 p7)
- p6 (mid p3 p9)
- p8 (mid p7 p9)
- )
- (nth (- site 1) (list p1 p2 p3 p4 p5 p6 p7 p8 p9))
- )
|