Cutting 3d element into smaller element

I’m trying to create smaller 3d element from this original model.

Attached here is a picture of a model i want to achieve.
The dynamo script attached is not working properly or its not properly executed.

PS: i have uploaded a sample REVIT model
this dynamo will be use to different shapes so cubes are not the only shape considered.
cuboid trial.dyn (34.3 KB)


@Andy_Grout