How do I create this object in Mechanical, through scripting?
Adapt the following code:
mesh = ExtAPI.DataModel.Project.Model.Mesh
extrude = mesh.AddPullExtrude()
extrude.Location = ExtAPI.SelectionManager.CurrentSelection # this scopes a face that is manually selected in Mechanical. Adapt this to your own needs. For robustness, using a named selection is recommended
extrude.Height = Quantity("2[mm]")