I want to cut a solid with other (ex: cubes) using script
A script like:
import bpy
context = bpy.context
scene = context.scene
cube1 = context.active_object
cube2 = cube1.copy()
cube2.data = cube1.data.copy()
cube1.scale = (2.0, 2.0, 0.9)
mod = cube1.modifiers.new("SomeName", type='BOOLEAN')
mod.operation = 'DIFFERENCE'
mod.object = cube2
bpy.ops.object.modifier_apply(apply_as='DATA', modifier=mod.name)
doesn't work.
I use Blender v2.82
The error said:
AttributeError: 'NoneType' object has no attribute 'modifiers'
What is wrong with my example
Maybe something is not selected, but what and how?
I try to change Blender version to 2.9301
and the error now is:
Traceback (most recent call last):
File "\Text", line 18, in <module>
File "E:\Programs\for_CAD3D\Blender2v901w64\2.90\scripts\modules\bpy\ops.py", line 201, in __call__
ret = op_call(self.idname_py(), None, kw)
TypeError: Converting py args to operator properties: : keyword "apply_as" unrecognized
Error: Python script failed, check the message in the system console
Could be an error from python version?
Best regards, Ciprian
cube1isNoneat the point where you try to accesscube1.modifiers. Probably you accidentally did not specify the appropriate active object before running your script. – NeverConvex Aug 27 '21 at 11:41