3
$\begingroup$

Using 2.90.0 Beta, I get a TypeError: Converting py args to operator properties: : keyword "apply_as" unrecognized

I believe this is coming from a Boolean modifier:

    context = bpy.context
    scene = context.scene
    tX = scene.objects.get("tX")
    tCut = scene.objects.get("tCut")
    if tX and tCut:
        bool = tX.modifiers.new(name='bool', type='BOOLEAN')
        bool.object = tCut
        bool.operation = 'DIFFERENCE'
        bpy.ops.object.modifier_apply(
                {"object": tX},
                apply_as='DATA',
                modifier=bool.name)

What's interesting is it's mentioning two other python files:

Error: Traceback (most recent call last):
  File "C:\Users\"user"\Desktop\Blender2.90\2.90\scripts\startup\panel_sidebar.py", line 131, in execute
    modifier=bool.name)
  File "C:\Users\"user"\Desktop\Blender2.90\2.90\scripts\modules\bpy\ops.py", line 199, in __call__
    ret = op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)
TypeError: Converting py args to operator properties: : keyword "apply_as" unrecognized

location: <unknown location>:-1

The panel_sidebar.py also contains the boolean function, but it wasn't being utilized. It throws a different error when it is utilized:

Error: Traceback (most recent call last):
  File "\panel_sidebar.py", line 125, in execute
    bool = tX.modifiers.new(name='bool', type='BOOLEAN')
AttributeError: type object 'tX' has no attribute 'modifiers'

The ops.py has never been touched. All of this has been working fine in 2.82 & 2.83. Thank you

$\endgroup$
0

1 Answer 1

5
$\begingroup$

This is not specific to boolean modifier. There was changes to python for modifiers. Remove the apply_as='DATA' and it should work.

Before we did

for data

bpy.ops.object.modifier_apply(apply_as='DATA')

for shapekey

bpy.ops.object.modifier_apply(apply_as='SHAPE')

Now we do

for data

bpy.ops.object.modifier_apply()

for apply shapekey

bpy.ops.object.modifier_apply_as_shapekey(keep_modifier=False)

for save shapekey

bpy.ops.object.modifier_apply_as_shapekey(keep_modifier=True)

To use multiple versions of Blender, you can do like this.

version = bpy.app.version

if version >= (2, 91, 0):
    bpy.ops.object.modifier_apply()    
else;    
    bpy.ops.object.modifier_apply(apply_as='DATA')
$\endgroup$
2
  • $\begingroup$ That works, thanks! Any issues with also using this retrospectively, within 2.83? (by taking out "apply_as='DATA'" there as well? Or do I need to have two versions? $\endgroup$
    – Increality
    Jul 24, 2020 at 19:18
  • 1
    $\begingroup$ I updated my answer with a solution, since you can't add code to comments. $\endgroup$
    – AFWS
    Jul 24, 2020 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .