Post #753: ![](https://blenderartists.org/user_avatar/blenderartists.org/yan.kansky/48/7141

πŸ“‹ Metadata

🏷️ Tags

macro python-scripting beginner solved

  • Stack Key Editor
  • Python Scripting
  • Macro Editor

πŸ’¬ Content

yan.kansky:

roaoao, I’m trying to make a button to move selected objects to center. It works if I type this text in β€œCommand”:

bpy.context.object.location[0] = 0

[ATTACH=CONFIG]489161[/ATTACH]

but for active object only. What do I need to add to the command to make it move not just one but all selected objects to center on one axis?

try this with stack keys in command tab

for i in bpy.context.selected_objects: i.location[0] = 0

this one is for X axis , change i.location[0] tp i.location[1] for Y axis , and i.location[2] for z axiz ,
and to make it all in center , i.location = [0,0,0]

Hope this works


πŸ”— View on Blender Artists