I have this code:

import bpy

# Reset 3D Cursor Rotation
bpy.context.scene.cursor.rotation_euler[0] = 0
bpy.context.scene.cursor.rotation_euler[1] = 0
bpy.context.scene.cursor.rotation_euler[2] = 0

Instead of referencing the same main parameter on three lines, can I write this in a single line?


# My question refers to what's within the < > chars; I want to include all 3 params within the brackets

bpy.context.scene.cursor.rotation_euler[<0 to 2>] = 0
  • $\begingroup$ bpy.context.scene.cursor.rotation_euler = [0] * 3 ? bpy.context.scene.cursor.rotation_euler[0:3] = [0] * 3 ? $\endgroup$
    – Gorgious
    Commented Jan 5, 2023 at 10:53
  • 1
    $\begingroup$ cursor.rotation_euler = (0,0,0) ?? $\endgroup$
    – Robin Betts
    Commented Jan 5, 2023 at 11:26
  • $\begingroup$ @Gorgious and @RobinBetts All of these worked great except the one I liked the most, from Robin, which omitted the bpy class method (should be bpy.context.scene.cursor.rotation_euler = (0,0,0)). So please add it as an answer, Robin, so I can mark the question solved. Many thanks to you as well, Gorgious! $\endgroup$
    – Henrik
    Commented Jan 5, 2023 at 11:50
  • $\begingroup$ Well it's arguably not even a Blender related question, I suggest you read a bit on python basics if you want to continue playing with the API :) $\endgroup$
    – Gorgious
    Commented Jan 5, 2023 at 12:57
  • $\begingroup$ @Gorgious Hmm. On the one hand I think you're absolutely right and looking at it from that angle, I totally agree. On the other hand, that would probably limit the type of code-related questions possible here (pertaining to things you want to do with Blender) down to very few. I don't know if there's a specific rule to the type of questions allowed in this regard but I definitely apologize if mine is to be considered too generic. The way I see it, Blender could actually be a great means to learn Python and therefore questions like this would arise. $\endgroup$
    – Henrik
    Commented Jan 6, 2023 at 16:22

1 Answer 1

bpy.context.scene.cursor.rotation_euler = (0,0,0)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .