1
$\begingroup$

How can I have two separate parts of a cut object with Boolean difference modifier in python code script?

My simple code

import bpy


context = bpy.context 
scene = context.scene

name1="face-1"
bpy.ops.mesh.primitive_cube_add(location = (0, 0, 1))
bpy.ops.transform.resize(value=(4, 4, 0.1))
face1 = bpy.context.object

face1.name = name1




bpy.ops.mesh.primitive_cube_add(location = (0, 0, 0))
bpy.ops.transform.resize(value=(2, 2, 2))
cube1 = bpy.context.object
solidname='Solid-0'
cube1.name = solidname


mod1 = cube1.modifiers.new("One1", type='BOOLEAN')
mod1.operation = 'DIFFERENCE'


mod1.object = face1
bpy.ops.object.modifier_apply(apply_as='DATA', modifier=mod1.name)

scene.update()
cube1.data = cube1.to_mesh(scene, True, 'PREVIEW')


scene.update()
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.