Geometry
Once the Geometry node is created (see Creating Model Components and Model Object Nodes) you can add geometric features to the node. For example, add a square using default position (0, 0) and default size 1:
model.geom("geom1").create("sq1", "Square");
The first input argument "sq1" to the create method is a tag, a handle, to the square. The second argument "Square" is the type of geometry object.
Add another square with a different position and size:
model.geom("geom1").create("sq2", "Square");
with(model.geom("geom1").feature("sq2"));
  set("pos", new String[]{"0.5", "0.5"});
  set("size", "0.9");
endwith();
The with statement in the above example is used to make the code more compact and, without using with, the code statements above are equivalent to:
model.geom("geom1").feature("sq2").set("pos", new String[]{"0.5", "0.5"});
model.geom("geom1").feature("sq2").set("size", "0.9");
Take the set difference between the first and second square:
model.geom("geom1").create("dif1", "Difference");
with(model.geom("geom1").feature("dif1").selection("input"));
  set(new String[]{"sq1"});
endwith();
with(model.geom("geom1").feature("dif1").selection("input2"));
  set(new String[]{"sq2"});
endwith();
To build the entire geometry, you call the method run for the Geometry node:
model.geom("geom1").run();
The above example corresponds to the following Geometry node settings:
In this way, you have access to the functionality that is available in the geometry node of the model tree. Use Record Code or any of the other tools for automatic generation of code to learn more about the syntax and methods for other geometry operations.
Removing Model Tree Nodes
You can remove geometry objects using the remove method:
model.geom("geom1").feature().remove("sq2");
Remove a series of geometry objects (circles) with tags c1, c2, ..., c10:
for (int n = 1; n <= 10; n = n+1) {
  model.geom("geom1").feature().remove("c"+n);
}
The syntax "c"+n automatically converts the integer n to a string before concatenating it to the string "c".
To remove all geometry objects:
for (String tag : model.geom("geom1").feature().tags()) {
  model.geom("geom1").feature().remove(tag);
}
However, the same can be achieved with the shorter:
model.geom("geom1").feature().clear();
In a similar way, you can remove other model tree nodes.