Post #432: Mighty Pea:

πŸ“‹ Metadata

  • Author: roaoao
  • Date: 2016-11-11 06:01:09
  • Type: answer
  • Quality Score: 9/10
  • Reply to: post_00431

🏷️ Tags

popup-dialog configuration advanced solved

  • Popup Dialog Editor
  • Python Scripting
  • Custom Icons

πŸ’¬ Content

Mighty Pea:

What would the edit mode version of this look like? So instead of object/lamp/camera etc. I’d want vertices, edges, faces, sculpt…

You want to use it in the same (bottom) position, right?
This code tries to find a popup dialog by name and draw it in this order:

None Object(if nothing is selected),
Vertex, Edge, Face,
(mesh edit mode)**,
Object, Edit, Pose, Sculpt, Vertex Paint, Weight Paint, Texture Paint, Particle Edit, Gpencil Edit, **
Mesh, Curve, Surface, Meta, Font, Armature, Lattice, Empty, Camera, Lamp, Speaker,
Any Object

So to use context sensitive bottom slot for vertex, edge, face and sculpt mode you need to add 4 popup dialogs and name them Vertext, Edge, Face, Sculpt.

Save this code as scripts/context_sensitive_slot.py file:

frame = kwargs.get("frame", False)

lh.save()

if frame:
    lh.box()

obj = C.selected_objects and C.active_object
if not obj:
    draw_menu("None Object") or lh.column()

elif obj.type == "MESH":
    if obj.mode == 'EDIT':
        msm = C.tool_settings.mesh_select_mode
        msm[0] and draw_menu("Vertex") or \
            msm[1] and draw_menu("Edge") or \
            msm[2] and draw_menu("Face") or \
            draw_menu("Edit") or \
            draw_menu("Mesh") or \
            draw_menu("Any Object") or lh.column()
    else:
        draw_menu(obj.mode.replace("_", " ").title()) or draw_menu("Mesh") or \
            draw_menu("Any Object") or lh.column()
else:
    draw_menu(obj.type.replace("_", " ").title()) or \
        draw_menu("Any Object") or lh.column()

lh.restore()

And use it as an external script in Custom tab:

execute_script("scripts/context_sensitive_slot.py", frame=True)

You can change frame value to False if you don’t need a frame.


πŸ”— View on Blender Artists