0
$\begingroup$

Why am I not seeing the trasformation takes place in the viewport? please help explain what I am missing?

def transform1(objs, location=(0, 0, 0), rotation=(0, 0, 0), scale=(1, 1, 1), mode='XYZ'):
    # Ensure we're operating in object mode
    bpy.ops.object.mode_set(mode='OBJECT')

    for obj in objs:
        # Set the location, rotation, and scale of each object
        obj.location = location
        obj.rotation_euler = Euler((rotation[0], rotation[1], rotation[2]), mode)
        obj.scale = scale
        
        # Make the object the active one
        bpy.context.view_layer.objects.active = obj
        obj.select_set(True)
        
        # Apply the transformations to the object data
        bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
        
        # Deselect the object
        obj.select_set(False)
    bpy.context.view_layer.update()
```
$\endgroup$
3
  • $\begingroup$ Sorry, I overlooked. The code I provided actually worked. $\endgroup$
    – taavartar
    Commented Dec 30, 2023 at 16:20
  • $\begingroup$ Hello and welcome. Please use proper code tags when posting code or error messages $\endgroup$ Commented Dec 30, 2023 at 19:10
  • $\begingroup$ how/where do you call your function? $\endgroup$ Commented Dec 30, 2023 at 22:59

0

You must log in to answer this question.

Browse other questions tagged .