How to control GridMap with GDScript

Godot Version

Godot 3.5

Question

How to control GridMap with GDScript.

Add collision detection and texture to a 1m side cube and place the cube in GridMap by using GDScript (via GDScript) to specify GridMap coordinates in the GridMap node instead of using the Inspector.

I would like sample code.

I don’t need answers like read the references or read the documentation.

Yes, you do! Assuming you’ve already set up the mesh library, this is literally just about calling a single, well documented function:

get_node("GridMap").set_cell_item(1, 2, 3, 0)

This will set the cell at position x = 1, y = 2, z = 3 with the 0-th (i.e. first) mesh in your library. That’s all.