Dear Enzo,
Thank you for your query.
You may possibly have better chances of getting a good answer asking in English.
You ask: how can I programmatically create a grid?
You can find many answers on the Internet by searching for 'revit api create grid':
https://duckduckgo.com/?q=revit+api+create+grid
The very first one that comes up does indeed address your question:
http://forums.augi.com/showthread.php?100405-Draw-Grid-Lines-using-Revit-API-in-C
Apparently, you create the Grid by feeding it with a geometric line or arc:
Line line = revitApp.Create.NewLineBound(sPoint, ePoint);
Grid g = revitApp.ActiveDocument.Create.NewGrid(line);
The NewGrid method is now obsolete, and replaced by the static Grid.Create method:
http://www.revitapidocs.com/2018/00ae8045-b65e-40b1-c162-ef5048fcf9f9.htm
That lead me to search the Internet again, this time for 'revit api grid.create':
https://duckduckgo.com/?q=revit+api+grid.create
That led to the Autodesk knowledge network article on grids:
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/Revit-API/files/GUID-...
As always when researching a Revit API task, it will help if you create the desired situation manually and explore that in depth, e.g., using RevitLookup, or other, more intimate, database exploration methods:
http://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-ontol...
http://thebuildingcoder.typepad.com/blog/2013/11/intimate-revit-database-exploration-with-the-python...
I hope this helps.
Best regards,
Jeremy