这个skill脚本可以用来计算layer的面积,包括Path、Rectange、Polygon。
用法:复制代码保存为 layer_area.il,
在icfb的CIW窗口
在layout界面选中要测量的图形, 按下 Alt+a 即可弹出所选图形的面积
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| /* Synopsis : CL_Area() */
procedure(CL_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 CLMessage("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 CLMessage("Error!!" 'Close "This is not a layer.") sprintf(area "Area = unknown") else sprintf(area "Area = %f" area) ) CLMessage("Layer Area" 'Close area) geDeselectFig(shape) );foreach
);prog );procedure
;------------------------------------------------------- procedure(CLMessage(title button message) prog( () hiDisplayAppDBox( ?name 'CLDBox ?dboxBanner title ?buttonLayout button ?dboxText message ) );prog );procedure
hiSetBindKey("Layout" "Alt<Key>a" "CL_Area()")
|