如何求任意平面多边形的中心点
各位高手,如何用CAD命令求任意平面多边形的中心点同问:P:P:P 通过搜索搞定。
思路是把多边形转换成面域 region, 再通过获取面域的参数得到中心点。
(defun C:xingxin()
(setq en (car(entsel "\n选取闭合曲线:")))
;(setvar "DELOBJ" 1)
(if ( /= (get-dxf 0 en) "REGION")
(progn
(command "region" en "")
(setq en (entlast))
));if
(setq
ENT (vlax-ename->vla-object en)
CEN (vlax-get ENT "centroid")
AREA (vlax-get ENT "AREA"))
(princ (strcat "\narea: " (rtos area 2 3)))
(princ (strcat "\ncentroid: " (vl-princ-to-string cen )))
(command "point" CEN )
(princ)
)
(defun get-DXF (code ename )
(cond ((= (type ename) 'ENAME)
(if (= code -3)
(cdr (assoc code (entget ename '("*"))))
(cdr (assoc code (entget ename)))
))
);COND
)
页:
[1]