# Gmsh: Recombine 2D in script file or command line

I have many STL files and I want to reduce their size, so I use Gmsh in this way:

gmsh -2 -bin -format vtk -o file.vtk file.stl -0

It reduces the size from 7 MB to 1.2 MB, but if I use the option "Recombine 2D" the size is reduced to 800 KB. I cannot find a way to use recombine in the command line, so I try with the next script file:

Merge "malla.stl";
Recombine Surface {1};


But it doesn't work. The only way that works Recombine 2D is in the graphical interface. How can I automate the command "Recombine 2D"?

Recombine Surface{1} - recombines only the triangles for the surface #1.

To allow recombination of all the surfaces, you need either Mesh.RecombineAll=1 or Recombine Surface {:};. Those commands will perform it on all the surfaces.

However, I find it a bit strange that you are using Recombine commands for that purpose. They are usually used to create a structured rectangular/quad mesh in certain regions of the model rather than reduce file size.

• Thanks, but it doesn't work. I try also try with ´Recombine Surface {:}´ and I get the same results. I understand that ´Recombine´ is used to crate structured rectangular mesh,but in this way I can reduce the file size too. I just need these STL to post-process, the calculations are already done. – xpt Jan 11 at 14:06