Create CompSolid

 1from salome.shaper import model
 2
 3model.begin()
 4partSet = model.moduleDocument()
 5Part_1 = model.addPart(partSet)
 6Part_1_doc = Part_1.document()
 7Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
 8CompSolid_1 = model.addCompSolid(Part_1_doc, [model.selection("SOLID", "Box_1_1")])
 9model.do()
10model.end()

Download this script