Post #4885: ![](https://blenderartists.org/user_avatar/blenderartists.org/adam_szalai/48/902

📋 Metadata

🏷️ Tags

v1-18-7 macro scripting advanced solved

  • Macro Editor
  • overlay function
  • Property Editor
  • Python Scripting

💬 Content

Adam_Szalai:

is there a way to address a PME macro (or other PME entity) in the status_notifier.py?

status_notifier.py is designed to display text in the 3D Viewport under certain conditions and is not inherently equipped to monitor the execution state of operators or macros. I attempted to devise a method for PME macros, but it proved ineffective—the text displayed only momentarily. Therefore, I recommend utilizing PME’s overlay function. If you wish to extend the display time, you can do so like this: overlay("Hello PME", duration=5.0).

However, you can reference properties created in PME like so:

def generate_text_lines(context):
    text_lines = []
    mode = context.mode
    tool_settings = context.tool_settings

    scene = context.scene

    if getattr(scene, 'my_custom_flag', False): # If the custom flag is True
        custom_text = scene.my_custom_text # Get custom text
        text_lines.append(custom_text) # Add to the list

    # ...

    return text_lines

For more on PME properties, you can refer to my previous posts.

Pie Menu Editor 1.18.7 Released Scripts and Themes

I am not an expert, and I will do my best to provide accurate information. Please be aware that there may be inaccuracies or unclear expressions in my explanation. If you find any mistakes in my explanation, please feel free to point them out. When you click the “Store in Addon Preferences” option, a selection screen like the one in the image appears. This is asking you where to save the data. [Pasted image 20230502012231] The list displayed here consists of subclasses called ID subclasses,…


Adam_Szalai:

How do You get the info about addressing for example boxcutter or any other tool

Are you referring to this snippet? if context.workspace.tools.from_space_view3d_mode('OBJECT').idname == "Boxcutter": This checks if the tool’s idname in the 3D Viewport in Object Mode matches “Boxcutter”.

For instance, if you want to find out the identifier of the active tool in Mesh Edit Mode, you can check it in the console like this. Since I was using the box selection tool, I got the string ‘builtin.select_box’.

>>> bpy.context.workspace.tools.from_space_view3d_mode('EDIT_MESH').idname
'builtin.select_box'

PME’s basic features allow you to create a variety of functionalities quite easily, but sometimes you might need to dig a little deeper for more complex solutions. In such cases, examining the source code of addons that have similar functions to what you’re aiming for can be incredibly enlightening. For example, I discovered how to check for an active Boxcutter tool by looking through the code of an addon named “sadcurcor.” These days, a quick Google search or a browse through the Blender API Reference can also point you in the right direction. Plus, you can always revisit this thread to see how knowledgeable folks like roaoao or Motiomancer tackle different challenges.

There might be a more straightforward approach out there—perhaps a programmer like roaoao has some tricks up their sleeve.
But hey, if you ever get stuck, don’t hesitate to drop a question here !


Adam_Szalai:

I tried running status_notifier.py under Blender 3.2
but nothing happens when i’m changing to Boxcutter.

I have an idea why that might be happening—it’s likely that not just the Boxcutter text, but none of the text is displaying.

Anyway, if something doesn’t work, I look for error messages.
I downloaded 3.2.2 and ran the script. Looking at Blender’s system console, I found this error:

TypeError: blf.size() takes exactly 3 arguments (2 given)

It’s saying blf.size() is missing an argument. Please add the third argument DPI=72.
blf.size(font_id, 50, 72) This should work.

The reason I only wrote two arguments is that I was aligning with the recent Blender Python API, which allows you to omit the third argument in the latest versions. Furthermore, from Blender 4.0, this third argument is removed, so having it will actually cause an error. I reported this here two weeks ago, but thanks to you, I realized that backward compatibility needs to be considered. I will report on this again.


Adam_Szalai:

Also don’t understand why i have to copy the py file to there instead of this location:

The reason I used PME autorun is simply that it’s the easiest way (and also, this is a discussion thread for PME topics).

There are several ways to execute functionality like status_notifier.
First, you could copy the code into Blender’s text editor and run it every time you launch Blender, which can be cumbersome.
Another way is to register it as an addon. The current script looks like it could be installed as an addon as is, but actually, it’s not quite sufficient to function as one.

I’m not a professional coder either, so when I have a functioning script, I want to use it right away. Running it every time in the text editor is a hassle, and I don’t want to go through the effort of completing the script as an addon. I wish someone would run this half-baked script automatically.(that’s where autorun comes in)


🔗 View on Blender Artists