analitics

Pages

Tuesday, June 14, 2022

Blender 3D and python scripting - part 017.

In this tutorial I will show you how you can apply an modifier in Blender 3D using the python script.
First, you need to comment these source code rows in order to allow to apply the modifier.
## now set up shape key in Blender
#mesh=obj_branch.data
#sk_basis = obj_branch.shape_key_add(name='Basis',from_mix=False)
#sk_basis.interpolation = 'KEY_LINEAR'
## must set relative to false here
#obj_branch.data.shape_keys.use_relative = False

## create new shape key
#sk = obj_branch.shape_key_add(name='Deform',from_mix=False)
#sk.interpolation = 'KEY_LINEAR'
#sk.slider_min = 0
#sk.slider_max = 2
You cannot aply an modifier if you have skape keys.
To apply an modifyer you can use this line of source code:
# this will apply the modifier named 'SK'
bpy.ops.object.modifier_apply( modifier = 'SK' )
If you go to the UV Editing area you will see the modifier is apply and you can create an UV map.