Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picking up the centroid?

Status
Not open for further replies.

bdickens

Mechanical
Sep 19, 2005
13
0
0
US
Hi,

I was wondering if anyone knew of a way to highlight or identify the centroid of an area in Autocad.

thanks

Barry.
 
Replies continue below

Recommended for you

Code:
(defun C:CENTROID (/ ent vla_poly vla_region centroid)
(vl-load-com)
(if
(and (setq ent (car (entsel "\nSelect a polyline: ")))
(eq (cdadr (entget ent)) "LWPOLYLINE")
(eq (vla-get-closed
(setq vla_poly (vlax-ename->vla-object ent))
)
:vlax-true
)
)
(progn
(setq vla_region
(car (vlax-safearray->list
(vlax-variant-value
(vla-addregion
(vla-objectidtoobject
(vla-get-document
vla_poly
)
(vla-get-ownerid
vla_poly
)
)
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbobject
(cons 0 (1- (length (list vla_poly))))
)
(list vla_poly)
)
)
)
)
)
)
(setq centroid (vlax-safearray->list
(vlax-variant-value
(vla-get-centroid vla_region)
)
)
)
(vla-delete vla_region)
)
)
centroid
)
(princ)

...borrowed somwhere in the www

Lothar

ADT 2004
ACAD 2002
 
Status
Not open for further replies.
Back
Top