Ok I have to be honest here, UIList are confusing and I haven't been able to find any good documentation to help me with this question:
How do I go about using IntProperty, BoolProperty, StringProperty, CollectionProperty, EnumProperty, properly with a UIList? I want to be able to pass those properties to other Operators and functions.
What I have tried:
The furthest I was able to get is the following:
class CUSTOM_UL_items(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
scene = context.scene
mytool = scene.my_tool
obj = item.obj
custom_icon = "OUTLINER_OB_%s" % obj.type
split = layout.split(factor=0.3)
split.label(text=f' {index}')
split.prop(mytool, "item1") # StringProperty from __init__.py
split.prop(mytool, "ruleEnum") # EnumProperty from __init__.py
split.prop(mytool, "item2") # StringProperty from __init__.py
def invoke(self, context, event):
pass
Where item1, ruleEnum, and item2
are defined in a PropertyGroup class:
# User input Property Group:
class BMNFTS_PGT_MyProperties(bpy.types.PropertyGroup):
# Rules for Logic:
logicBool: bpy.props.BoolProperty(name="Logic")
item1: bpy.props.StringProperty(name="item1")
ruleEnum: bpy.props.EnumProperty(
name="",
description="Select DNA Rule",
items=[
('Only with', "Only with", "Only with Rule"),
('Never with', "Never with", "Never with Rule")
]
)
item2: bpy.props.StringProperty(name="item2")
Here is a git repo I created for this question, it's completely self contained so you can easily set it up in Blender with just the zipped init.py file: https://github.com/torrinworx/Blender_UList/blob/main/__init__.py
The panel is located in the 3D View after you install it to Blender, press the 'N' key when in the 3D viewport to open the side view. The panel name is Blender_UIList
.
This is what it looks like:
In the above UIList there are two StringProperty and one EnumProperty with two values in the drop down. There are multiple issues with this setup:
- I cannot call these individually by the UIList index and use them in an
execute
function Operator. (or at least I don't know how) - Each Index shows the same values for each Property, if you change
item1
index 0 to 5 for example,item1
index 1 and 2 would be set to 5. So each element in the UIList isn't 'independent'.
Resources I've found/used:
And yes, I have checked out the following links:
- Create an interface which is similar to the material list box
- How to create a custom UI?
- https://sinestesia.co/blog/tutorials/amazing-uilists-in-blender/
I did find this repo that looks like it has possibly an IntProperty within a UIList: https://github.com/p2or/blender-loom
Here is his example:
I can't really say I understand what it does, but it seems to be what I'm looking for. However main file has almost 5000 lines of code and I wouldn't even know where to start.
Summary of questions
How do I create a UIList where each item in the list contains it's own independent Property (StringProperty, IntProperty, EnumProperty, etc.)?
How do I call the Properties in that UIList? For example, pass them to an execute
function with an Operator?
I can't tell if it's a logic thing that I'm struggling to understand with the UIList, or just some Blender UI method in general I'm completely unaware of. Anyhow, I really appreciate the communities help on this one, thank you for your time!
Torrin