Request active_slot OR update Property Chat with Array

Property Chat is a great Addon for Sync Property.
But can’t access into Array with format - “materials[0] OR textures[‘new.001’]”.

It’s diffculty to access Influence panel To change Diffuse color or something else.
Cuz use_map_diffuse … are under texture_slots (not texture).

The problem is There’s no active_material.active_texture.active_slot And
We can’t use active_material.texture_slots[0].use_map_diffuse.

So. many available propertys have been abandoned.

Maybe a active_slot is better.

Thanks!

there’s no shortcut, but it’s possible:

mat = bpy.context.object.active_material
mat.texture_slots[mat.active_texture_index].use_map_diffuse = True

Thanks for your nice addon And reply. CoDEmanX.

I’ve changed some codes Want to implement “materials[0] OR textures[‘new.001’]”.

But I failed for use strings-key-index to access in the textures tuple. (check comment note in codes)

Good news is materials[0] (array[<int>]) is working.

@ line 118 -> changing begin


def obj_prop_get(obj, attr_string):
    """return a pair (rna_base, "rna_property") to give to the rna UI property function"""
    attrs = attr_string.split(".", 2)
    #import re
    #attrs = re.findall('(.*?[])}]?)\.', attr_string+'.')
    
    val_new = obj
    for i, attr in enumerate(attrs):
        val_old = val_new
        if '[' not in attr:
            val_new = getattr(val_old, attr, Ellipsis)
        else:
            attr, index = attr.replace(']','').split('[')
            val_new = getattr(val_old, attr, Ellipsis)
            try:
                index = int(index)
                val_new = val_new[index]
            except:
                print('Don\'t support string index')
                val_new = None
                """
                # Why my 'text' not in ['text'] ?
                index = str(index).strip()
                if index in val_new.keys():
                    val_new = val_new[index]
                else:
                    print("%s not in %s" % (index, val_new.keys()))
                    val_new = None
                """    
        if val_new == Ellipsis:
            return None, None
    return val_old, attrs[-1]

Want to implement “materials[0] OR textures[‘new.001’]”

i don’t understand…

what is the code doing you posted? looks pretty complicated.

Sorry for my strange expressing methods.

The buildin addon Property Chart can’t support to Get “data.vertices[0].co” (I know Copy to selected can do it. just example).

If we can get “data.vertices[0].co”. We can get any array element. So. I try to do something.

And I try to use strings-index to access Dict/Hash (eg. textures[‘new.001’]).

Some strange things happening.(eg. ‘text’ not in [‘text’] )

So. I comment strings-index part. Wish for a help.

If you remove the comments I left.

You can see this:


def obj_prop_get(obj, attr_string):
    """return a pair (rna_base, "rna_property") to give to the rna UI property function"""
    attrs = attr_string.split(".", 2)

    val_new = obj
    for i, attr in enumerate(attrs):
        val_old = val_new

        if '[' not in attr:
            val_new = getattr(val_old, attr, Ellipsis)
        else:
            attr, index = attr.replace(']','').split('[')
            val_new = getattr(val_old, attr, Ellipsis)
            try:
                index = int(index)
                val_new = val_new[index]
            except:
                print('Don\'t support string index')
                val_new = None
   

        if val_new == Ellipsis:
            return None, None
    return val_old, attrs[-1]

Well. I guess it’s Clean lot :slight_smile: