the fair gds editor DxfLoadMacro

DXF load

In DXF files any coordinate is saved without a physical unit. No information on the used units is included. So to open a DXF file additional information is required to open it with the correct scale. By defaul the LayoutEditor use the current setting of userunits for it.

DXF Load Macro

This macro will load a DXF file. It will not use the default userunit as physical units, but it will ask for the DXF units before it opened the file.

Download: DXFload.layout

   1 #!/usr/bin/layout
   2 #name=dxf load
   3 #help=loads a file and ask for userunits if it is a DXF file
   4 
   5 
   6 int main(){
   7         layout->closeDesign(); // close, if a design is still open
   8         string fileName=layout->getOpenFilename();
   9         string resultName=fileName;
  10         string extension=fileName.mid(fileName.length()-4);
  11         if ((extension==".DXF")||(extension==".dxf")){
  12                 // setting correct units for a DXF file
  13                 string units= layout->getText("units","Units? (um,mm,nm)","mm");
  14                 layout->drawing->databaseunits=0.000000001;
  15                 if (units=="um")layout->drawing->userunits=0.001;
  16                 else if (units=="µm")layout->drawing->userunits=0.001;
  17                 else if (units=="mm")layout->drawing->userunits=0.000001;
  18                 else if (units=="nm")layout->drawing->userunits=1;
  19                 else {
  20                         layout->drawing->userunits=0.001;
  21                         layout->showMessage("???","unknow units, using µm");
  22                 }
  23                 resultName=fileName;
  24                 }
  25         else 
  26              resultName=fileName;
  27         //open file
  28         layout->drawing->openFile(fileName);
  29         layout->drawing->userunits=0.001;
  30         layout->filename=resultName;
  31         layout->drawing->scaleFull();
  32 }

See also


CategoryMacro


DxfLoadMacro (last edited 2011-02-24 19:25:23 by dslb-092-074-059-143)