hiSetBindKey("Layout" "F9" "smpGUIPadExtract()")
procedure(smpGUIPadExtract()
let( ()
padlayerName=hiCreateStringField(
?name `padlayerName
?prompt "Layer Name"
)
padlayerPpos=hiCreateStringField(
?name `padlayerPpos
?prompt "Layer Purpose"
)
padangleOff=hiCreateFloatField(
?name `padangleOff
?prompt "Angle Offset (-90 to 90 degree)"
?defValue 15.0
)
padorder =hiCreateCyclicField(
?name `padorder
?prompt "Order"
?choices list("clockwise" "anticlockwise")
?defValue "clockwise"
)
padsizeFilter=hiCreateFloatField(
?name `padsizeFilter
?prompt "Pad size must larger than"
?defValue 0.0
)
padInstDepth=hiCreateIntField(
?name `padInstDepth
?prompt "Pad instances flatten depth (1~32)"
?defValue 32
)
refPointCoorX=hiCreateFloatField(
?name `refPointCoorX
?prompt "Reference point coordinate X"
?defValue 0.0
)
refPointCoorY=hiCreateFloatField(
?name `refPointCoorY
?prompt "Reference point coordinate Y"
?defValue 0.0
)
PEForm=hiCreateAppForm(
?name `padExtractForm
?formTitle "Extract PAD Location"
?callback `dosmpPadExtract(hiGetCurrentForm())
?fields list(
padlayerName
padlayerPpos
padorder
padsizeFilter
padangleOff
padInstDepth
refPointCoorX
refPointCoorY
)
)
layerDefValue=nth(0 leGetEntryLayer())
pposDefValue=nth(1 leGetEntryLayer())
padExtractForm->padlayerName->value=layerDefValue
padExtractForm->padlayerPpos->value=pposDefValue
hiDisplayForm(`padExtractForm)
)
)
procedure( dosmpPadExtract(myForm)
let( ()
layerName=myForm->padlayerName->value
layerPpos=myForm->padlayerPpos->value
order =myForm->padorder->value
padsizeFilter=myForm->padsizeFilter->value
angOffset0=myForm->padangleOff->value
padInstDepth=myForm->padInstDepth->value
refPointCoorX=myForm->refPointCoorX->value
refPointCoorY=myForm->refPointCoorY->value
padLayer=list(layerName layerPpos)
smpPadExtract( padLayer order angOffset0 padsizeFilter padInstDepth refPointCoorX refPointCoorY)
)
)
procedure(smpPadExtract(padLayer order angOffset0 filtersize padInstDepth refPointCoorX refPointCoorY)
let( ( anticlockwise myPinName )
cv=geGetWindowCellView();
cellName = cv~>cellName;
libName = cv~>libName;
viewName = cv~>viewName;
viewName2 = strcat("padExtract" viewName);
;cv2id=ddGetObj(libName cellName viewName2);
while( ddGetObj(libName cellName viewName2)
;printf("Trying delete unused temp vellview , LIB : %s CELL %s VIEW: %s \n " libName cellName viewName2);
viewName2 = strcat(viewName "New" )
)
cv2=dbCopyCellView(cv libName cellName viewName2);
;cv2=dbOpenCellViewByType(libName cellName viewName2 "maskLayout" "w" )
; Select the center of cell to compute the angle then to sort clockwise
cv2CenterX=0.5*(leftEdge(cv2~>bBox)+rightEdge(cv2~>bBox));
cv2CenterY=0.5*(topEdge(cv2~>bBox)+bottomEdge(cv2~>bBox));
;angOffset0=15
angOffset=atan2((0-cv2CenterY) (0-cv2CenterX))+angOffset0*3.1415926/360;
; Select All toplevel Text
pins=setof(x cv2~>shapes x~>theLabel)
foreach(inst cv2~>instances
dbFlattenInst(inst padInstDepth t);
)
dbSave(cv2)
padsAll=setof(x cv2~>shapes x~>lpp==padLayer)
padsFiltered='nil
foreach(a padsAll
wa=rightEdge(a~>bBox) - leftEdge(a~>bBox)
ha=topEdge(a~>bBox) - bottomEdge(a~>bBox)
if( wa >= filtersize && ha >= filtersize then
padsFiltered=append(padsFiltered list(a))
)
)
pads=sort( padsFiltered
'lambda( ( a b )
xac=0.5*(leftEdge(a~>bBox)+rightEdge(a~>bBox));
yac=0.5*(topEdge(a~>bBox)+bottomEdge(a~>bBox));
xbc=0.5*(leftEdge(b~>bBox)+rightEdge(b~>bBox));
ybc=0.5*(topEdge(b~>bBox)+bottomEdge(b~>bBox));
angA=atan2((yac-cv2CenterY) (xac-cv2CenterX));
angB=atan2((ybc-cv2CenterY) (xbc-cv2CenterX));
when(angA<angOffset
angA =angA+2*3.14159;
);
when(angB<angOffset
angB =angB+2*3.14159;
);
if(order=="anticlockwise" then
angA<angB;
else
angA>angB;
)
)
)
; liujin create a file to store the pad location, the file name is cellname + _padLoacation
file=strcat(cv~>cellName "_padLoacation")
; open the file to write to
outf=outfile(file)
; fprintf is used to write to a file in specific format
fprintf(outf "create time: %s\n" getCurrentTime())
fprintf(outf "%-20s %10s %10s %10s %10s\n" "Name" "centerX" "centerY" "width" "length")
printf("Pad Name \t Pad X \t Pad Y \t Pad Openings W x H \n");
foreach( pad pads
xc=0.5*(leftEdge(pad~>bBox)+rightEdge(pad~>bBox)) - refPointCoorX;
yc=0.5*(topEdge(pad~>bBox)+bottomEdge(pad~>bBox)) - refPointCoorY;
wa=rightEdge(pad~>bBox) - leftEdge(pad~>bBox);
ha=topEdge(pad~>bBox) - bottomEdge(pad~>bBox);
;printf("PAD X: %L \t Y : %L \n" xc yc);
angA=atan2((yc-cv2CenterY) (xc-cv2CenterX))
when(angA<angOffset
angA =angA+2*3.14159;
)
myPinName='nil
foreach(a pins
coor=a~>xy
coorx=nth(0 coor)
coory=nth(1 coor)
;printf("TextX : %10L TextY : %10L \n" coorx coory)
if( leftEdge(pad~>bBox)<=coorx && coorx<=rightEdge(pad~>bBox) && bottomEdge(pad~>bBox)<=coory && coory<=topEdge(pad~>bBox) then
myPinName=append(myPinName list(a))
)
)
pinText=myPinName~>theLabel
printf("%L \t %L \t %L \t %L x %L\n" pinText xc yc wa ha);
;liujin change
fprintf(outf "%L \t %L \t %L \t %L x %L\n" pinText xc yc wa ha);
)
dbClose(cv2);
cv2id=ddGetObj(libName cellName viewName2);
ddDeleteObj(cv2id);
)
; close the file
close(outf)
; view the location file
view(file)
printf("Please find result: %s\n" file)
;;;;;;;;;;;;;;liujin
)
标签:name,坐标,cv2,value,pad,LOCATION,file,PAD,bBox
From: https://www.cnblogs.com/jinzbr/p/18235707