📋 Metadata

💬 Content

JoseConseco:

So now I would have to split it in to 4 commands (bounds, wire, solid…) as in your example. But if there was option for each menu item: ‘iterate over selection’, this would be great. I would work like this
for obj in selectedObj’s:
context.scene.objects.active=obj
doThatStuffFromMenuItem

I don’t want to add context sensitive features like iterating selected objects. There are hundreds of variations for that iterating (selected/unselected, mesh/lamp, visible/hidden, etc.). Some users don’t work with objects at all.

For context sensitive commands you can use python code. And it’s pretty fast actually.
In your case you can use single-line code:

[setattr(obj, "draw_type", 'WIRE') for obj in bpy.data.objects if obj.type == 'MESH' and obj.select]

For complex (multi-line) commands you can execute external python script:

execute_script("scripts/my_command.py")

🔗 View on Blender Artists