Mustard2 / MustardUI

Custom UI for Blender human models. It features automatic outfits switch, custom properties support, armature panel creation, and much more.
https://mustard3d.eu
MIT License
318 stars 30 forks source link

[Suggestion] Add the ability to select the Property's Subtype from within the MustardUI Custom properties settings #149

Open DestinyPlayer opened 10 months ago

DestinyPlayer commented 10 months ago

I strongly prefer using the Factor subtype for most of the properties that I stick into MustardUI, but whenever you add a new property to it, it defaults to Plain Data. So I have to go back into the Armature's Data and change them all there.

It would be much more seamless if you could do it from within MustardUI itself, as a new option within Property Settings.

Mustard2 commented 10 months ago

Hi!

I missed this, but I guess I can try to implement it. :)

Is there any documentation about this?

DestinyPlayer commented 10 months ago
import bpy
context = bpy.context
obj = context.object

if obj.type == "ARMATURE":
    print("Armature got!")
    arm = obj.data

print("Try to detect an object's custom properties")

if len(arm.keys()) > 1:
    print("Object",obj.name,"custom properties:")
    for k in arm.keys():
        if k not in badprops:
            print( k , "-", arm[k])
            if !isinstance(arm[k], float):
                print("    That ain't a float mate")
            else:
                print("    This is a float! Changing property to factor")
                propertychange = arm.id_properties_ui(k)
                propertychange.update(
                    subtype="FACTOR"
                )
else:
    print("This object has no custom properties!")

I'm not certain about proper documentation, but I have managed to cobble this together in order to save myself some time while working on my last rigging project. Maybe this can help, at least with giving more specific notes for finding docs?

EDIT: https://docs.blender.org/api/current/bpy.props.html Best I got is this

Mustard2 commented 10 months ago

Ah nice, I guess the key stuff here is the subtype="FACTOR" . I think it can be done, I'll check it :)