; set default value to form field
axlFormBuildPopup( ps_RefDestoCenter_From "select_layer_name" lLayer_name )
axlFormSetField( ps_RefDestoCenter_From "select_layer_name" "Assembly TOP" )
axlFormSetField( ps_RefDestoCenter_From "Sym_mode" t )
axlFormSetFieldVisible( ps_RefDestoCenter_From "aspcRun" 0 )
axlFormDisplay( ps_RefDestoCenter_From )
deleteFile( ps_RefDestoCenter_From_file )
; default visible layer is Assembly Top
axlVisibleDesign( nil )
axlVisibleLayer( "Board Geometry/Assembly_TOP" t )
axlVisibleLayer( "Board Geometry/Outline" t )
axlVisibleLayer( "Drawing Format/Title_Block" t )
axlVisibleLayer( "Drawing Format/Outline" t )
axlVisibleLayer( "Package Geometry/Assembly_Top" t )
axlVisibleLayer( "Ref Des/Assembly_Top" t )
axlVisibleLayer( "Pin/Top" t )
axlFlushDisplay()
sPackageLayer = "PACKAGE GEOMETRY/PLACE_BOUND_BOTTOM"
axlMsgPut( "Please select a symbol to move its Refdes in By Symbol mode;" )
axlMsgPut( "or select a layer to move all the Refdes in By Layer mode!" )
while( bStop
bSym = axlFormGetField( ps_RefDestoCenter_From "Sym_mode" )
bLayer = !bSym
while( bStop && bSym
axlFormSetFieldVisible( ps_RefDestoCenter_From "aspcRun" 0 )
axlSetFindFilter(?enabled '("NOALL" "symbols" ) ?onButtons '("symbols" ))
axlMsgPut( "Please select a symbol to Move its Refdes." )
if( axlSelect() then
lSym = axlGetSelSet( )
; get text block info, store them in a list
; if some block text are not rotate 0, 90, 180 or 270 degree, then need to re-create a some block text
; and get its block info
lBlock = nil
foreach( dText lText
unless( member( dText->textBlock lBlock )
lBlock = cons( dText->textBlock lBlock )
if( dText->rotation == 0.0 || dText->rotation == 180.0
then
fDelta_y = ( cadadr( dText->bBox ) - cadar( dText->bBox ) )*0.32
else
if( dText->rotation == 90.0 || dText->rotation == 270.0
then
fDelta_y = ( caadr( dText->bBox ) - caar( dText->bBox ) )*0.32
else
rText_orient = make_axlTextOrientation(
?textBlock dText->textBlock, ?rotation 0.0,
?mirrored dText->isMirrored, ?justify dText->justify
)
bText_status = caar( axlDBCreateText( dText->text, 0:0, rText_orient, dText->layer, nil ) )
fDelta_y = ( cadadr( bText_status->bBox ) - cadar( bText_status->bBox ) )*0.32
axlDeleteObject( list( bText_status ) )
)
); end if
lBlock = cons( fDelta_y lBlock )
)
); end foreach
lBlock = reverse( lBlock )
; move RefDes to Symbol Body Center
foreach( dSym lSym
lShape = nil
sPackageLayer = "PACKAGE GEOMETRY/PLACE_BOUND_BOTTOM"
unless( dSym->isMirrored
sPackageLayer = "PACKAGE GEOMETRY/PLACE_BOUND_TOP"
)
foreach( dChild dSym->children
when( dChild->objType == "shape" && dChild->layer == sPackageLayer
lShape = cons( dChild lShape )
)
); end foreach child
; when one symbol got more than one place boundry shapes,
; need to find the largest one.
when( lShape
dShape_temp = car( lShape )
unless( onep( length( lShape ) )
for( n 1 length( lShape ) - 1
dShape = nth( n lShape )
unless( axlDistance( car( dShape->bBox ) cadr( dShape->bBox ) ) < \
axlDistance( car( dShape_temp->bBox ) cadr( dShape_temp->bBox ) )
dShape_temp = dShape
)
); end for
); end unless
; get text block info, store them in a list
; if some block text are not rotate 0, 90, 180 or 270 degree, then need to re-create a some block text
; and get its block info
lBlock = nil
foreach( dText lText
unless( member( dText->textBlock lBlock )
lBlock = cons( dText->textBlock lBlock )
if( dText->rotation == 0.0 || dText->rotation == 180.0 then
fDelta_y = ( cadadr( dText->bBox ) - cadar( dText->bBox ) )*0.32
else
if( dText->rotation == 90.0 || dText->rotation == 270.0 then
fDelta_y = ( caadr( dText->bBox ) - caar( dText->bBox ) )*0.32
else
rText_orient = make_axlTextOrientation(
?textBlock dText->textBlock, ?rotation 0.0,
?mirrored dText->isMirrored, ?justify dText->justify
)
bText_status = caar( axlDBCreateText( dText->text, 0:0, rText_orient, dText->layer, nil ) )
fDelta_y = ( cadadr( bText_status->bBox ) - cadar( bText_status->bBox ) )*0.32
axlDeleteObject( list( bText_status ) )
)
); end if
lBlock = cons( fDelta_y lBlock )
)
); end foreach
lBlock = reverse( lBlock )
; move RefDes to Symbol Body Center
foreach( dSym lSym
lShape = nil
sPackageLayer = "PACKAGE GEOMETRY/PLACE_BOUND_BOTTOM"
unless( dSym->isMirrored
sPackageLayer = "PACKAGE GEOMETRY/PLACE_BOUND_TOP"
)
foreach( dChild dSym->children
when( dChild->objType == "shape" && dChild->layer == sPackageLayer
lShape = cons( dChild lShape )
)
); end foreach child
; when one symbol got more than one place boundry shapes,
; need to find the largest one.
when( lShape
dShape_temp = car( lShape )
unless( onep( length( lShape ) )
for( n 1 length( lShape ) - 1
dShape = nth( n lShape )
unless( axlDistance( car( dShape->bBox ) cadr( dShape->bBox ) ) < \
axlDistance( car( dShape_temp->bBox ) cadr( dShape_temp->bBox ) )
dShape_temp = dShape
)
); end for
); end unless
; get symbol RefDes, and move it to this shape center
foreach( dText lText
when( dText->parent == dSym && dText->text == dSym->refdes && substring( dText->layer 1 7 ) == "REF DES"
; here still need to check original text orientation, and adjust text coordinate about 0.32 times
fDelta_y = cadr( member( dText->textBlock lBlock ) )
if( dText->isMirrored then
; if do not care some special degrees, like 90.287
; it will be easy
caseq( round( dSym->rotation / 45.0 )
( ( 0 1 2 7 )
fText_rot = round( dSym->rotation / 45.0 ) * 45.0
)
( ( 3 4 5 6 )
fText_rot = round( dSym->rotation / 45.0 ) * 45.0 + 180.0
)
);end case
else
caseq( round( dSym->rotation / 45.0 )
( ( 0 1 2 7 )
fText_rot = round( dSym->rotation / 45.0 ) * 45.0
)
( ( 3 4 5 6 )
fText_rot = round( dSym->rotation / 45.0 ) * 45.0 + 180.0
)
);end case
);end if
bText_status = car( axlDBCreateText( dText->text, fSym_xy, rText_orient, dText->layer, dSym ) )
when( bText_status
axlDeleteObject( dText )
)
); end when
); end foreach
); end when
); end foreach dSym
); end for
when( nCheck_All > 0
axlVisibleDesign( nil )
axlVisibleLayer( "Board Geometry/Assembly_TOP" t )
axlVisibleLayer( "Board Geometry/Outline" t )
axlVisibleLayer( "Package Geometry/Assembly_Top" t )
axlVisibleLayer( "Ref Des/Assembly_Top" t )
axlVisibleLayer( "Board Geometry/SilkScreen_TOP" t )
axlVisibleLayer( "Package Geometry/SilkScreen_Top" t )
axlVisibleLayer( "Pin/Top" t )
axlVisibleLayer( "Ref Des/SilkScreen_Top" t )
axlVisibleLayer( "Route Keepin/All" t )
axlVisibleLayer( "Route Keepout/Top" t )
axlVisibleLayer( "Board Geometry/Assembly_Bottom" t )
axlVisibleLayer( "Package Geometry/Assembly_Bottom" t )
axlVisibleLayer( "Ref Des/Assembly_Bottom" t )
axlVisibleLayer( "Board Geometry/SilkScreen_BOTTOM" t )
axlVisibleLayer( "Package Geometry/SilkScreen_Bottom" t )
axlVisibleLayer( "Pin/Bottom" t )
axlVisibleLayer( "Ref Des/SilkScreen_Bottom" t )
axlVisibleLayer( "Route Keepin/All" t )
axlVisibleLayer( "Route Keepout/BOTTOM" t )
axlFlushDisplay()
axlShell( "redisplay" )
)
); end aspcRun
( "aspcHelp"
axlCancelEnterFun( )
axlClearSelSet( )
nvhtmBrowser( nvmmrbc_HELPPAGE )
)
); end case
); end let
); end ps_RefDestoCenter_Routine