2
$\begingroup$

I'm a beginner and I just want to set the location, rotation, and scale of the object. I tried to get code by reverse engineering but when I moved, rotated, and scaled my object I saw complicated code.

enter image description here

$\endgroup$
4
$\begingroup$

if you want to get exact code you shouldn't change transform in view port. when you change the transform in this panel it works:

enter image description here

enter image description here

Location

import bpy

obj = bpy.context.object
obj.location = (0,0,0)

Rotation

import bpy
import math

obj = bpy.context.object
obj.rotation_euler = (0,math.radians(90),0)

Scale

import bpy

obj= bpy.context.object
obj.scale = (1,1,1)
$\endgroup$
3
  • 1
    $\begingroup$ @RobinBetts thank you I fixed it $\endgroup$ Aug 28 '20 at 8:24
  • $\begingroup$ AFAIC setting the matrix basis values absolutely (as above) and transforming are totally different. These are showing only the resultant local transform. Related eg rotating the cube in question image again around the view axis, or moving globally cannot be simply crunched into fields. In the most part initial values can be set when the object is created. $\endgroup$
    – batFINGER
    Aug 28 '20 at 14:15
  • $\begingroup$ @batFINGER thank you for sharing! I didn't see this post $\endgroup$ Aug 28 '20 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.