;;;从AutoCAD 2013 Active Reference帮助中code Examples中提取
;;;本源代码由 xshrimp 2013.2.20 搜集整理,版权归原作者所有!
(vl-load-com)
(defun c:Example_Perimeter()
;; This example creates a region from an arc and a line.
;; It then returns the length of the perimeter of the region.
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
(setq modelSpace (vla-get-ModelSpace doc))
;; Create the arc and line
(setq centerPoint (vlax-3d-point 5 3 0)
radius 2
startAngle 0
endAngle 3.141592)
(setq arcObj (vla-AddArc modelSpace centerPoint radius startAngle endAngle))
(setq lineObj (vla-AddLine modelSpace (vla-get-StartPoint arcObj) (vla-get-EndPoint arcObj)))
(setq curves (vlax-make-safearray vlax-vbObject '(0 . 1)))
(vlax-safearray-put-element curves 0 arcObj)
(vlax-safearray-put-element curves 1 lineObj)
;; Create the region
(setq regionObj (vla-AddRegion modelSpace curves))
(vla-ZoomAll acadObj)
;; Find the perimeter of the region.
(setq perimeter (vla-get-Perimeter (vlax-safearray-get-element (vlax-variant-value regionObj) 0)))
(alert (strcat "The perimeter of the region is " (rtos perimeter 2)))
)