# API: Overview

Be sure to have installed the SDK or have compiled GMSH using the `ENABLE_LIB` options. See the first section of this course for more information.
This section assumes that you are familiar with GMSH inner languages and Python.

## (Important) Remarks

• Online documentation is exhaustive
• Numerous detailed examples are given in the source code of GMSH. In particular, you should definitely have a look at `t1.py`, `t2.py`, `t3.py`, … where the commands are very well detailed and explained.
• This tutorial only uses Python but both C++ and Julia work with the SDK!
• Everything you learn prior to this part is still valid (and will actually help you), only the syntax changes (good news!). For example, adding a point (`Point(i)={x,y,z,h}`) becomes `gmsh.model.geo.addPoint(x,y,z,h,i);`.

Let start with a circle centered on (0,0) of radius R=1. The code can be the following:

``````import gmsh
import sys
import math

# Init GMSH
gmsh.initialize(sys.argv)
# Ask GMSH to display information in the terminal
gmsh.option.setNumber("General.Terminal", 1)

# Create a model and name it "MyCircle"
model = gmsh.model

# Parameters
h = 0.1 # Mesh size

# Create Point for the center of the circle
# Create 3 Points on the circle
points = []
for j in range(3):
# Create 3 circle arc
lines = []
for j in range(3):
# Curveloop and Surface

# Physical groups
# gmsh.model.addPhysicalGroup(dim, list of tags, physical tag)

# This command is mandatory and synchronize CAD with GMSH Model. The less you launch it, the better it is for performance purpose
gmsh.model.geo.synchronize()
# Mesh (2D)
model.mesh.generate(2)
# Write on disk
gmsh.write("MyDisk.msh")
# Launch the GUI (not mandatory at all)
gmsh.fltk.run();
# Finalize GMSH
gmsh.finalize()
``````

Launching it via the following command

``````python mycircle.py
``````

should open a GMSH window with a meshed disk

Using Python API, rebuild the “L-shape” geometry.

Let us redo the CAD example using the Python API. This example can also be downloaded from the source code of GMSH:

``````# This reimplements gmsh/demos/boolean/boolean.geo in Python.
import gmsh
import sys

model = gmsh.model
factory = model.occ

gmsh.initialize(sys.argv)

gmsh.option.setNumber("General.Terminal", 1)

gmsh.option.setNumber("Mesh.Algorithm", 6);
gmsh.option.setNumber("Mesh.CharacteristicLengthMin", 0.4);
gmsh.option.setNumber("Mesh.CharacteristicLengthMax", 0.4);

R = 1.4; Rs = R*.7; Rt = R*1.25

factory.intersect([(3, 1)], [(3, 2)], 3)