# How do I scale object location without scaling the object itself (Transform affect only location)

I'm trying to write a part of a script that would scale object locations away from the 3d cursor (so the object size itself wouldn't change, but the object would move away from the 3d cursor). It works perfectly fine in the 3d view when I'm not using code and have location selected in the transform affect only options, but I can't get it to work on python code. Here's my (not working) code:

bpy.context.scene.tool_settings.use_transform_pivot_point_align = True
bpy.ops.transform.resize(value=(1.5, 1.5, 1.5))


Right now it just scales the active object where it is instead of what I need it to do. Thanks in advance!

Scaling in the sense you mean is really scaling the distance between the 3D cursor and the object. Here's an example, step-by-step that does that. It can be written much simpler but this is meant to show the details:

import bpy
from mathutils import Vector

# Assuming you want to scale each dimension differently
scale_x = 1.0
scale_y = 2.0
scale_z = 3.0

# An object to move away from the 3D cursor.
object = bpy.context.active_object

object_location = object.location
cursor_location = bpy.context.scene.cursor.location

# Calculate how far apart the cursor and object are now
delta = object_location - cursor_location

# Calculate how far apart they should be
scaled_delta = delta * Vector((scale_x, scale_y, scale_z))

# Calculate the location the object should move to
object_location = cursor_location + scaled_delta

# move it
object.location = object_location


There are other ways to do this, and this could be simplified, of course.