Post #5006: I’m really happy to talk about PME Property.

📋 Metadata

🏷️ Tags

property-editor python-scripting advanced solved

  • Property Editor
  • Python Scripting

💬 Content

I’m really happy to talk about PME Property.

Please try entering the following:

# getter
return props().PropsHumanEnum

# setter
props().PropsHumanEnum = value

Your approach this time was a new discovery for me. The default values for getter and setter, self.get(menu, hoge) and self[menu], actually work, don’t they? I had been ignoring these until now. I will investigate this further.

Additionally, as a bonus, I will explain about Python’s data types and the direct access method to props.

You were trying the following method, which seems a bit wrong to me (I’m surprised it works). When surrounded by single quotes, it is just a string of props().PropsHumanEnum.

# getter
return self.get(menu, 'props().PropsHumanEnum')

As an alternative to this, the following code could be considered. However, due to my lack of research, it may not operate stably. Please use the method I showed earlier as a basic approach.

# getter
return self.get(menu, props().PropsHumanEnum)

What I want you to pay attention to is that props().PropsHumanEnum is not enclosed in single quotes ('). This allows you to specify the property that returns the string PropsHumanEnum held by the props() method.

If you are interested in props(), try checking the value of props directly in the Blender console. Please paste the following code directly into the console.

# Import the necessary module from Pie Menu Editor
from pie_menu_editor.ed_property import props

# Accessing the property using the props() method
# Here we retrieve the current value of PropsHumanEnum
pme_property = props().PropsHumanEnum
print(f'type: {type(pme_property)}, value: {pme_property}')

# Setting a new value to the PropsHumanEnum property using the props() method
# In this case, we are setting it to 'Item1'
pme_property = props().PropsHumanEnum = 'Item1'
print(f'type: {type(pme_property)}, value: {pme_property}')

# Accessing the property directly from the PME addon preferences
# Here we access the PropsHumanEnum property directly from the PME addon preferences
prefs = bpy.context.preferences.addons['pie_menu_editor'].preferences
direct_access_property = prefs.props.PropsHumanEnum
print(f'type: {type(direct_access_property)}, value: {direct_access_property}')

# Setting a new value to the PropsHumanEnum property directly via PME addon preferences
# In this case, we are setting it to 'Item3'
direct_access_property = prefs.props.PropsHumanEnum = 'Item3'
print(f'type: {type(direct_access_property)}, value: {direct_access_property}')

imageimage1752×968 212 KB


❤️ 1 likes


🔗 View on Blender Artists