Hello
I am new with Blender and Scripting.
I would like (an exercise) to set up a Menger Sponge.
I am able to prepare all the components …
![Sponge_3|519x425]
But I am unable to perform the right code to make the difference of TheCube and all the other objects.
I prepared a very simple code as follow
import bpy
TheSize=3
TheWidth=5
bpy.ops.mesh.primitive_cube_add(size=TheSize, enter_editmode=False, location=(0, 0, 0))
bpy.context.object.name = “BigCube”
bpy.ops.mesh.primitive_cube_add(size=TheSize/3, enter_editmode=False, location=(0, 0, 0))
bpy.context.object.name = “CenterThirdX”
bpy.ops.transform.resize(value=(TheWidth, 1, 1))
bpy.ops.mesh.primitive_cube_add(size=TheSize/3, enter_editmode=False, location=(0, 0, 0))
bpy.context.object.name = “CenterThirdY”
bpy.ops.transform.resize(value=(1, TheWidth, 1))
bpy.ops.mesh.primitive_cube_add(size=TheSize/3, enter_editmode=False, location=(0, 0, 0))
bpy.context.object.name = “CenterThirdZ”
bpy.ops.transform.resize(value=(1, 1, TheWidth))
bpy.ops.object.select_all(action=‘DESELECT’)
How to (by script) make the Menger Sponge Order 1
The result, in symbolic code, seems like : BigCube - (CenterThirdX + CenterThirdY - CenterThirdZ)
I tried different methods (even by hand) … The result is not good ! !
Cna you help me !
Best regards
Pascal