Post #415: ![](https://blenderartists.org/user_avatar/blenderartists.org/nanomanpro/48/1874

šŸ“‹ Metadata

šŸ·ļø Tags

macro python-scripting intermediate solved

  • Macro Editor
  • Python Scripting

šŸ’¬ Content

Nanomanpro:

roaoao You are genius:)

I’m trying to understand this pattern but I’m too weak in python, so I have one more question.
How can I modify this code only for selected objects, and when no object is selected for all meshes?

Thx

You need to find seleced meshes (selected_meshes) and use them instead of all meshes (meshes).

This code should work:

meshes = [o for o in bpy.data.objects if o.type == 'MESH']; selected_meshes = [o for o in bpy.context.selected_objects if o.type == 'MESH']; meshes = selected_meshes or meshes; global show_wire; show_wire = meshes and not meshes[0].show_wire; [setattr(m, "show_wire", show_wire) for m in meshes]

šŸ”— View on Blender Artists