Post #1974: Hi, @Sebastian_cg

πŸ“‹ Metadata

🏷️ Tags

pie-menu property custom-scripting advanced solved

  • Property Editor
  • Custom Icons
  • Python Scripting
  • EnumProperty

πŸ’¬ Content

Hi, @Sebastian_cg

Sebastian_cg:

1 icon toggle like check box if the layer is visible or not
2 smaller icon if it is possible

  1. afaik it’s impossible. bpy.ops.object.hide_collection operator uses internal layer visibility data which is not available for add-ons
  2. no it’s impossible

You can add an EnumProperty in PME for this tool.
Here is an example (download and import): layers_property.json

LayersProperty Getter:

ls = locals(); ls.update(ret=0); [ls.update(ret=ls["ret"] | 1 << i) for i, col in enumerate(C.scene.collection.children) if not col.hide_viewport]; return ls["ret"]

LayersProperty Setter:

[setattr(col, "hide_viewport", not value & 1 << i) for i, col in enumerate(C.scene.collection.children)]

To use this Property in Custom tab use this code:

c = L.column(align=True); [c.prop_enum(props(), "LayersProperty", str(i + 1), text=col.name) for i, col in enumerate(C.scene.collection.children)]

πŸ”— View on Blender Artists