Post #1974: Hi, @Sebastian_cg
π Metadata
- Author: roaoao
- Date: 2019-02-14 16:40:15
- Type:
answer - Quality Score: 8/10
- Reply to: post_01972
- Replies (1): post_01975
π·οΈ Tags
pie-menu property custom-scripting advanced solved
βοΈ Related PME Features
- 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
- afaik itβs impossible.
bpy.ops.object.hide_collectionoperator uses internal layer visibility data which is not available for add-ons - 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)]