- ;instance/pcellpatterncell
- (procedure getinstbbox(instance layername)
- let((shapes bboxlist x_list y_list getinstbbox)
- shapes=instance~>master~>shapes
- bboxlist=list()
- x_list=list()
- y_list=list()
- foreach(ss shapes
- if(ss~>layerName==layername then
- x_list=append1(x_list car(dbTransformPoint(nth(0 ss~>bBox) dbGetInstTransform(instance))))
- x_list=append1(x_list car(dbTransformPoint(nth(1 ss~>bBox) dbGetInstTransform(instance))))
- y_list=append1(y_list nth(1 dbTransformPoint(nth(0 ss~>bBox) dbGetInstTransform(instance))))
- y_list=append1(y_list nth(1 dbTransformPoint(nth(1 ss~>bBox) dbGetInstTransform(instance))))
- bboxlist=append1(bboxlist list(dbTransformPoint(nth(0 ss~>bBox) dbGetInstTransform(instance)) dbTransformPoint(nth(1 ss~>bBox) dbGetInstTransform(instance))))
- )
- )
- x_list=sort(x_list 'lessp)
- y_list=sort(y_list 'lessp)
- getinstbbox=list(bboxlist x_list y_list)
- getinstbbox
- )
- )
- ;instancelayer
- (procedure getinstlayermaxbbox(instance layername)
- let((W H XMax Xmin YMax YMin bboxlist WHList)
- WHList=list()
- bboxlist=getinstbbox(instance layername)
- XMax=nth(length(nth(1 bboxlist))-1 nth(1 bboxlist))
- XMin=car(nth(1 bboxlist))
- YMax=nth(length(nth(2 bboxlist))-1 nth(2 bboxlist))
- YMin=car(nth(2 bboxlist))
- W=XMax-XMin
- H=YMax-YMin
- WHList=list(XMin XMax YMin YMax W H)
- WHList
- )
- )
- ;layer spaceinstancesarray
- ;x
- (procedure autoarrayinstance(aligndirection rownumber colnumber xlayer ylayer xspace yspace)
- let((shapes instances i sorted_instances_y sorted_inst_y sorted_instances_x xstart arr rowarr upinstBottom sorted_rowarr targetinstLeft sorted_inst sorted_inst_x targetinstTop lastinstRight)
- if(aligndirection=="X" then
- shapes=geGetSelSet()
- println(length(shapes))
- instances=setof(x shapes x~>objType=="inst")
- sorted_instances_y=sort(instances lambda((a b) nth(1,a~>xy) >= nth(1,b~>xy)))
- sorted_inst_y=nth(1,nth(0 sorted_instances_y)~>xy)
- instances=setof(x shapes x~>objType=="inst")
- sorted_instances_x=sort(instances lambda((a b) nth(0,a~>xy) <= nth(0,b~>xy)))
- xstart=nth(0,nth(0 sorted_instances_x)~>xy)
- arr=list()
- ;i-1n-1
- i=0
- rowarr=list()
- upinstBottom=nth(3 getinstlayermaxbbox(car(sorted_instances_y) ylayer))+yspace
- foreach(obj sorted_instances_y
- if(i<colnumber then
- rowarr=append1(rowarr obj)
- i=i+1
- )
- if(i==colnumber || obj==nth(i sorted_instances_y) then
- ;nlistlistylist
- sorted_rowarr=sort(rowarr lambda((a b) nth(0,a~>xy) <= nth(0,b~>xy)))
- ;nxy
- foreach(sorted_inst sorted_rowarr
- targetinstLeft=nth(0 getinstlayermaxbbox(sorted_inst xlayer))
- ;x +shift
- if(sorted_inst==car(sorted_rowarr) then
- sorted_inst_x=xstart
- else
- sorted_inst_x=nth(0 sorted_inst~>xy)-(targetinstLeft-xspace-lastinstRight)
- )
- targetinstTop=nth(3 getinstlayermaxbbox(sorted_inst ylayer))
- sorted_inst_y=nth(1 sorted_inst~>xy)+(upinstBottom-targetinstTop-yspace)
- sorted_inst~>xy=list(sorted_inst_x sorted_inst_y)
- println(sorted_inst~>xy)
- println(sorted_inst~>xy)
- lastinstRight=nth(1 getinstlayermaxbbox(sorted_inst xlayer))
-
- )
- upinstBottom=nth(2 getinstlayermaxbbox(car(sorted_rowarr) ylayer))
- rowarr=list()
- i=0
- )
- )
- )
- if(aligndirection=="Y" then
- shapes=geGetSelSet()
- instances=setof(x shapes x~>objType=="inst")
- sorted_instances_x=sort(instances lambda((a b) nth(0,a~>xy) <= nth(0,b~>xy)))
- sorted_inst_x=nth(0,nth(0 sorted_instances_x)~>xy)
- instances=setof(x shapes x~>objType=="inst")
- sorted_instances_y=sort(instances lambda((a b) nth(1,a~>xy) >= nth(1,b~>xy)))
- ystart=nth(1,nth(0 sorted_instances_y)~>xy)
- arr=list()
- ;i-1n-1
- i=0
- colarr=list()
- leftinstRight=nth(0 getinstlayermaxbbox(car(sorted_instances_x) xlayer))-xspace
- foreach(obj sorted_instances_x
- if(i<rownumber then
- colarr=append1(colarr obj)
- i=i+1
- )
- if(i==rownumber || obj==nth(i sorted_instances_x) then
- ;nlistlistylist
- sorted_colarr=sort(colarr lambda((a b) nth(1,a~>xy) >= nth(1,b~>xy)))
- ;nxy
- foreach(sorted_inst sorted_colarr
- targetinstTop=nth(3 getinstlayermaxbbox(sorted_inst ylayer))
- ;y +shift
- if(sorted_inst==car(sorted_colarr) then
- sorted_inst_y=ystart
- else
- sorted_inst_y=nth(1 sorted_inst~>xy)-(targetinstTop+yspace-upinstBottom)
- )
- targetinstLeft=nth(0 getinstlayermaxbbox(sorted_inst xlayer))
- sorted_inst_x=nth(0 sorted_inst~>xy)+(leftinstRight-targetinstLeft+xspace)
- sorted_inst~>xy=list(sorted_inst_x sorted_inst_y)
- println(sorted_inst~>xy)
- upinstBottom=nth(2 getinstlayermaxbbox(sorted_inst ylayer))
-
- )
- leftinstRight=nth(1 getinstlayermaxbbox(car(sorted_colarr) xlayer))
- colarr=list()
- i=0
- )
- )
- )
- )
- )
- procedure( CreateAutoArrayForm( )
- ; let( ( rowIntField colIntField alignRadioField xrefStringField yrefStringField xspaceStringField yspaceStringField)
- let(()
- ;; creating the fields
- rowIntField =
- hiCreateIntField(
- ?name 'rowIntField
- ?prompt "Row number:"
- )
- colIntField =
- hiCreateIntField(
- ?name 'colIntField
- ?prompt "Column number:"
- )
-
- alignRadioField =
- hiCreateRadioField(
- ?name 'alignRadioField
- ?choices '( "X" "Y" )
- ?prompt "first align direction:"
- ?value "X"
- )
- alignRadioField2 =
- hiCreateRadioField(
- ?name 'alignRadioField2
- ?choices '( "X" "Y" )
- ?prompt "first align direction:"
- ?value "X"
- ?callback
- list(
- lambda((field scope selection)
- let((editable)
- editable=if(selection=="On" t nil)
- hiGetCurrentForm()->eddyStringField1->editable=editable
- hiGetCurrentForm()->eddyStringField2->editable=editable
- )
- )
- )
- )
- xrefStringField =
- hiCreateStringField(
- ?name 'xrefStringField
- ?prompt "X Reference layer:"
- )
- yrefStringField =
- hiCreateStringField(
- ?name 'yrefStringField
- ?prompt "Y Reference layer:"
- )
- xspaceFloatField =
- hiCreateFloatField(
- ?name 'xspaceFloatField
- ?prompt "X space:"
- )
- yspaceFloatField =
- hiCreateFloatField(
- ?name 'yspaceFloatField
- ?prompt "Y space:"
- )
- ;; creating the form
- hiCreateAppForm(
- ?name '__autoArrayForm__
- ?formTitle "Auto Array"
- ;?initialSize list( 300 260 )
- ?fields list(
- list(
- alignRadioField
- 15:5 350:25 200
- )
- list(
- rowIntField
- 15:35 250:25 200
- )
- list(
- colIntField
- 300:35 250:25 200
- )
- list(
- xrefStringField
- 15:80 250:25 200
- )
- list(
- yrefStringField
- 300:80 250:25 200
- )
- list(
- xspaceFloatField
- 15:120 250:25 200
- )
- list(
- yspaceFloatField
- 300:120 250:25 200
- )
- )
- ?callback "autoarrayinstance(alignRadioField~>value rowIntField~>value colIntField~>value xrefStringField~>value yrefStringField~>value xspaceFloatField~>value yspaceFloatField~>value)
- "
- )
- ) ;; close let
- ) ;; close procedure
- procedure( BFautoArrayForm( )
- unless( boundp( '__autoArrayForm__ ) && hiIsFormDisplayed( __autoArrayForm__ )
- CreateAutoArrayForm( )
- )
- hiDisplayForm( __autoArrayForm__ )
- ) ;; close procedure
- hiSetBindKey("Layout" "Super<Key>A" "BFautoArrayForm()")
复制代码 |