Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-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
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

Make your area a region (use the "region" command). Then Tools > Inquiry > Region/Mass Properties
 
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.

Part and Inventory Search

Sponsor