Post #3020: ![](https://blenderartists.org/user_avatar/blenderartists.org/hirasawayui/48/132

πŸ“‹ Metadata

🏷️ Tags

macro popup-dialog python-scripting advanced solved

  • Macro Editor
  • Regular Menu
  • Custom Python Scripting
  • Operator execution
  • UV map management

πŸ’¬ Content

HirasawaYui:

All objects have 2 UV cards. When you select all the objects and click on the map, the last object will have UVmap2 and the rest will have UVmap1. Is it possible to use PME to create a macro to select the last active UV map if all objects have the same number.

Add a new Regular Menu with 1 slot and use this code in Custom tab (or import this file):

uvs = sorted({k for obj in C.selected_objects if hasattr(obj.data, "uv_layers") for k in obj.data.uv_layers.keys()}); [operator(L, "pme.exec", text=uv, icon='UV', cmd="[setattr(obj.data.uv_layers, 'active', obj.data.uv_layers['%s']) for obj in C.selected_objects if hasattr(obj.data, 'uv_layers')]" % uv) for uv in uvs]

It generates a list of UVMap buttons which apply selected uvmap on selected objects

HirasawaYui:

How can I work with the β€œif, else, then and or” commands inside the PME.

If-else:

[True-execution] if [condition] [else] [False-execution]

If:

[True-execution] if [condition] [else] None

Also check this post


❀️ 4 likes


πŸ”— View on Blender Artists