Scripting PartDesign Workbench

Introduction
Here we will explain to you how to control the PartDesign using a script. Be sure to browse the Scripting section and the FreeCAD Scripting Basics pages if you need more information about how Python scripting works in FreeCAD. If you are new to Python, it is a good idea to first read the Introduction to Python.

This code aim to replicate the solid shown in:

https://wiki.freecad.org/Basic_Part_Design_Tutorial_019

Following are some preamble lines, that will ease the process.

using this code, when relaunching the script, if there is an existing document with the specified name, it will be emptied and all the objects are rebuild, avoiding to have many documents that will pollute the interface.

In case of some intermediate work, is interesting, you could always save it using.