Navigation:  C/C++ Scripting Engine > Sample C/C++ Script Code >

add_then_enlarge.c

Previous pageReturn to chapter overviewNext page

Add Polygons, then calculate copper Area.  Enlarge Polygons, and then calculate copper again.  Output to Fab3000 command window.

bar_dot

 

#include "Fab3000.h"

 

int main ()

{

 //Set user units to inch.

 dbSetUserUnits( dbcInch );

 

 //Create Layer

 uiEditAddLayer( "metal", 1 );

 

 //Create Outer Polygon

 dbPointArray arPts;

 arPts.appendPt( 0,0 );

 arPts.appendPt( 2.5,0.1 );

 arPts.appendPt( 2.6,3.0 );

 arPts.appendPt( 1.0,2.2 );

 arPts.appendPt( 0,2.5 );

 arPts.appendPt( 0,0 );

 uiAddPolygon( 1, 0, &arPts );

 

 //Create Inner Polygon (notice its a clear composite)

 arPts.clear();

 arPts.appendPt( 1,0.5 );

 arPts.appendPt( 2,1.0 );

 arPts.appendPt( 2,2.0 );

 arPts.appendPt( 1.2,2.0 );

 arPts.appendPt( 1,0.5 );

 uiAddPolygon( 1, 1, &arPts );

 

 //Calculate Copper Area for layer

 float fCopperArea = uiToolsCopperAreaCalculation( 1, dbcInch );

 

 //Output message

 dbLayer myLayer;

 dbGetLayer( 1, &myLayer );

 char buffer[200];

 sprintf( buffer, "Copper Area for Layer: \"%s\"  is  %.6f (sq. inch)", myLayer.getName(), fCopperArea );

 princ( buffer );

 

 //Now Lets Increase Size & place on a new layer

 dbSelectionSet sset;

 int nCount = sset.selectAll();

 if( nCount )

 {

         //Add New Layer

         uiEditAddLayer( "metal_offset", 2 );

 

         //Copy select to new layer

         dbIntArray arCopyLayers;

         arCopyLayers.append( 2 );

         uiEditCopyToLayers( &sset, &arCopyLayers );

 

         //Select objects on new layer 2

         sset.clear();

         sset.setLayerFilter( &arCopyLayers );

         nCount = sset.selectAll();

 

         //Enlarge Objects by 0.1 inch

         uiToolsEtchCompensation( &sset, 0.1 );

 

         //Calculate new copper area

         dbGetLayer( 2, &myLayer );

         fCopperArea = uiToolsCopperAreaCalculation( 2, dbcInch );

         sprintf( buffer, "After Enlargment, Copper Area for Layer: \"%s\"  is  %.6f (sq. inch)", myLayer.getName(), fCopperArea );

         princ( buffer );

 }

 

 //Zoom All

 uiViewZoomAll();

 return 0;

}