你可以在开始时使用这个
- (defun c:CEN (/ SS C CEN)
- (princ "\nSelect polygones: ")
- (if (setq SS (ssget '((0 . "LWPOLYLINE"))))
- (progn
- (setq C 0)
- (repeat (sslength SS)
- (setq CEN
- (kr:GOE_GetCentroidCoordinates
- (vlax-Ename->vla-Object (ssname SS C))
- )
- )
- (entmakex
- (list
- (cons 0 "CIRCLE")
- (cons 10 (trans CEN 1 0))
- (cons 40 2)
- )
- )
- (setq C (1+ C))
- )
- )
- (princ "\n** Nothing selected **")
- )
- (princ)
- )
- ; ============================================================ ;
- ; Get centroid coordinates ;
- ; Obj - VLA object ;
- ; ============================================================ ;
- (defun kr:GOE_GetCentroidCoordinates (Obj / RA PT TEMP)
- (if
- (not
- (vl-catch-all-error-p
- (setq RA
- (vl-catch-all-apply
- 'vlax-invoke
- (list
- (vla-get-modelspace
- (vla-get-document Obj)
- )
- 'AddRegion
- (list Obj)
- )
- )
- )
- )
- )
- (progn
- (setq PT
- (vlax-get
- (setq TEMP (car RA))
- 'Centroid
- )
- )
- (vla-delete TEMP)
- )
- )
- PT
- )
克鲁格 |