analitics

Pages

Thursday, June 2, 2022

Blender 3D and python scripting - part 010.

In this tutorial, I will use the source code from the previous tutorial and with the selected mesh I will resize and translate it on an axis then I will select the newly selected mesh and I will rotate it to obtain a roof shape.
This is the source code I used:
bpy.ops.object.mode_set(mode = 'EDIT') 

# let set the object mode 
bpy.ops.object.mode_set(mode="OBJECT")
# resize the selected areas 
bpy.ops.transform.resize(value=(1, 2, 1))
# translate 
bpy.ops.transform.translate(value=(0, 0.25, 0.31))

# rotate selected only if not is the initial mesh 
for ob in bpy.context.selected_objects:
    if ob.name != 'Plane-Y+Z':
        ob.rotation_euler[0] = pi/-4
        ob.convert_space(from_space='LOCAL', to_space='WORLD')

# define the new camera named NewCamera
See the result of this source code: