4
$\begingroup$

I'm trying to write my first add-on that should tell me the summary length of selected edges in edit mode if there are any. I got the part with getting selected edges and counting sum length, but what I am currently struggling to do is

  1. to get add-on invoked on each edge select/deselect
  2. to update the sum value to display result on the bottom statusbar (where the name of the active object, amount of vertices/edges/faces are displayed)

    For the first one I guess there could be some sort of callback/delegate that I could assign for every select and deselect to be invoked, but I don't know which to use. For the second I guess (and hope) I just need to know which variable to use.

I'm using blender 2.8.71 beta if that matters. Thanks

$\endgroup$
3
$\begingroup$

I only answer the second one for you since it is a little bit hard to find. But it is actually very useful in many case.

status_text_set(string)

status_text_set(text) in bpy.types.WorkSpace(ID):

classmethod status_text_set(text)

Set the status bar text, typically key shortcuts for modal operators

  • Parameters: text (string) – Text, New string for the status bar, None clears the text

So we can bpy.types.WorkSpace.status_text_set("hello world") to set the status bar, cool.

Or since context got an workspace as well, use context.workspace.status_text_set("foo") will be a better idea when using in operator or function which has it own context. - @batFINGER

hello world

Important

Clear the content by assign it a None, or it will keep showing there until next function call. You should consider clear it after you leave your operator.

$\endgroup$
  • 1
    $\begingroup$ Cool could also use the instance context.workspace.status_text_set("foo") $\endgroup$ – batFINGER May 24 at 16:12
  • $\begingroup$ @batFINGER Yeah, that should be better than access bpy.types. $\endgroup$ – Hikariztw May 25 at 1:05
  • $\begingroup$ Thanks @Hikariztw. Unfortunately I am currently unable to use blender and check how that will work for me but I will do it to the end of the next week. Also, regarding the first question. If it is a very common question how to invoke add-on method on each edge select/deselect, could you please refer me to another SO thread or perhaps an article describing that since I failed to find a clear explanation on my own. $\endgroup$ – J. Doe May 25 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.