- ;;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))
- )
|