获取块的中心点
请教各位,怎么能获取块的中心点?通过组码只能获取到插入点。:Q-取得图块最小包络线,再用liuhe提供的程序,可暂时实现。谢谢大家:handshake
;;----------------=={ Minimum Bounding Box }==----------------;;
;;Arguments: ;;
;;en - selection set to process ;;
;;pr - precision of calculation, 0 < pr < 1
(defun LM:MinBoundingBox ( en pr / an ba bb bm cn cv i l mb )
(if en
(progn
(setq bb
(LM:ListBoundingBox
(setq l (cons (vla-copy (vlax-ename->vla-object en)) l))
)
)
(setq pr (* pr pi)
cn (apply 'mapcar (cons (function (lambda ( a b ) (/ (+ a b) 2.0))) bb))
cv (vlax-3D-point cn)
bm (* (- (caadr bb) (caar bb)) (- (cadadr bb) (cadar bb)))
mb (cons 0.0 bb)
an 0
)
(while (< (setq an (+ an pr)) pi)
(foreach x l (vla-rotate x cv pr))
(setq bb (LM:ListBoundingBox l)
ba (* (- (caadr bb) (caar bb)) (- (cadadr bb) (cadar bb)))
)
(if (< ba bm) (setq bm ba mb (cons an bb)))
)
(foreach x l (vla-delete x))
(LM:RotatePointsByMatrix
(mapcar
(function
(lambda ( a )
(mapcar (function (lambda ( b ) ((eval b) (cdr mb)))) a)
)
)
'((caar cadar) (caadr cadar) (caadr cadadr) (caar cadadr))
)
cn (- (car mb))
)
)
)
) ;;45 [功能] 返回封闭曲线质心二维坐标
;; 示例: (MJ:Centroid (car (entsel)))
(defun c:tt()
(princ(MJ:Centroid (car (entsel))))
(princ))
(defun MJ:Centroid (poly / pl ms va reg cen)
(setq *ACAD*(vlax-get-acad-object)
*DOC* (vla-get-ActiveDocument *ACAD*))
(vl-load-com)
(setq pl (vlax-ename->vla-object poly)
ms (vla-get-modelspace
*DOC*
)
va (vlax-make-safearray vlax-vbObject '(0 . 0))
)
(vlax-safearray-put-element va 0 pl)
(setq reg (car (vlax-safearray->list
(vlax-variant-value (vla-addregion ms va))
)
)
cen (vla-get-centroid reg)
)
(vla-delete reg)
(vlax-safearray->list (vlax-variant-value cen))
)
(defun hlkx ( en / s )
(if en
(entmakex
(append
(list
(cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 90 4)
(cons 70 1)
)
(mapcar '(lambda ( p ) (cons 10 p)) (LM:MinBoundingBox en 0.001))
)
)
)
(entlast)
) 算包围盒对角点 再计算对角点中点 块中心点怎么定义的呢? 块的几何中心? 做成编组 通过编程识别另一个图元名 进行判断修改
都是一些简单的、对称性的多边形等。描述可能不准确。 ;; (setq pt (ECenter (setq s1(car(entsel"\n选择: ")))))
(defun ECenter (s1 / a b)
(vla-getboundingbox(vlax-ename->vla-object s1)'a'b)
(mapcar'(lambda(x y)(*(+ x y)0.5))(vlax-safearray->list a)(vlax-safearray->list b))
) 这个问题你们考虑简单了,XCLIP块,需要支持的!
页:
[1]
2