| ||
https://bbs.eetop.cn/thread-378631-1-1.html的11楼
Synopsis : JW_Area()
Version : 1.0
Create Date : 2006-03-28
Author : Justin Wang
E-Mail : justin727@gmail.com
*/
;hiSetBindKey("layout" "<Key>3" "JW_Area()")
procedure(JW_Area()
prog((cvId selObj area number shape Box points point1 point2 length width )
cvId = getEditRep(hiGetCurrentWindow())
selObj = geGetSelSet(cvId)
number = length(selObj)
if(zerop(number) then
JWMessage("Error!!" 'Close "Please select a layer." )
return()
)
geDeselectAll(hiGetCurrentWindow())
foreach(shape selObj
area = 0
case( shape~>objType
("rect"
Box = shape~>bBox
area = (car(cadr(Box)) - car(car(Box))) * (cadr(cadr(Box)) - cadr(car(Box)))
)
("polygon"
number = length(shape~>points)
points = shape~>points
points = append(points list(car(points)))
while(!zerop(number)
point1 = car(points)
points = cdr(points)
point2 = car(points)
area = area + ( car(point1) * cadr(point2) )
area = area - ( car(point2) * cadr(point1) )
number--
);while
area = abs(area/2)
)
("path"
number = shape~>nPoints
points = shape~>path
width = shape~>width
while(!zerop(number-1)
point1 = car(points)
points = cdr(points)
point2 = car(points)
if(equal(car(point1) car(point2))
length = abs(cadr(point1) - cadr(point2))
length = abs( car(point1) - car(point2))
);if
area = area + length * width
number--
);while
case(shape~>pathStyle
("extendExtend" area = area + width*width )
("varExtendExtend" area = area + (shape~>beginExt+shape~>endExt)*width )
("roundRound" area = area + 4/9.0 * width * width ) ;(w/3^2) * 4
(t );truncateExtend
);case
)
(t
area = 0.0
)
);case
geSelectObject(shape)
if(zerop(area) then
JWMessage("Error!!" 'Close "This is not a layer.")
sprintf(area "Area = unknown")
else
sprintf(area "Area = %f" area) 将Area=xx填入后赋值给area,给后续的JWMessage作为message元素
)
JWMessage("Layer Area" 'Close area)
geDeselectFig(shape)
);foreach
);prog
);procedure
;-------------------------------------------------------
procedure(JWMessage(title button message)
prog( ()
hiDisplayAppDBox(
?name 'JWDBox
?dboxBanner title
?buttonLayout button
?dboxText message
)
);prog
);procedure