Have some problem for a custom New Sculpt UI Addon

Hello, I’m just a noob of python and blender API with 5 evenings of knowledge xD and… I have been developing my first addon during this week for an all-in-one interface for the sculpt mode, with which to dispense with panels or other regions to just focus on sculpting and streamlining the workflow. I had an issue when Blender bring back and put new tool header buttons cause I didn’t have enought space for this addon and also I found there is a lot of unusable space that I couldn’t use. So, what I did yerterday to “fix” it was just overwriting the class ‘VIEW3D_HT_tool_header’ in my init file where my other ui classes are, to be able to just put there what I wanted, but eh… I have another problem, this affect to all modes, so Sculpt Mode is more than OK but other modes there is just void space, so I can write new tool header for all them but it is not the thing…

So, I tried so much things but with no results and need some help to solve it and be able to just modify the tool header of the sculpt mode without detroying other modes. I’ll be gratefull to all posible help and feedback! :blush:

Preview of the actual state of the addon

I openned a post about this addon (previous version) on blender.today

I also want to add support to new future features from Pablo Dobarro and so on to make a better integration with that powerfull features

First, let me just apologize if I misunderstand you. Also, let me just admit that I’m not particularly knowledgeable of Python. Also, I am approaching the resolution to your problem with taking your lack of knowledge of the Blender Python api into account.

Do you just want to know what code to change to ONLY affect the “Sculpt Mode” code?

If so, then just open up the Text Editor and right click on the tool buttons of the “Sculpt Mode” and then select “Edit Source”. This will take you straight to the buttons Python code.

The code that you mostly need to look for to change is code that is executed within the condition 'SCULPT' . 'SCULPT' is one of the possible values of context.mode

I wouldn’t quickly or easily know of any good way to rearrange the tool header code to reduce clutter - if that’s what you want.

1 Like

Yeah, I have that condition using the context.mode as the first thing in my custom tool header ui class, so it does good and only shows in Sculpt Mode, so the problem is that 1, without overwriting the original class VIEW3D_HT_tool_header, I mean declaring a class in the addon with the same name, I just get artifacts and intersections due to the lack of space and some big unusable space, and 2, overwriting that class I get what I want for only Sculpt Mode because I already programmed it with another class and with that condition, but the tool header of the other modes is empty due to the overwrite. So I need a way of say ok I want this class to be overwritten when I’m in sculpt mode, but the rest of modes I just want to stay it.

I hope it’s clearer with this explanation, I also tried some things googling and so to fix this issue but with no luck… probably what I want to do it’s not the easiest or most convenient but I can’t think in something better

Where even is VIEW3D_HT_tool_header? I can’t find it. My Blender version is about 1-2 months old - so maybe I just don’t have the class at all.

You might be able to import VIEW3D_HT_tool_header then, using the SCULPT condition, you could try using unregister_class(VIEW3D_HT_tool_header). Then use the register_class(VIEW3D_HT_tool_header) after your code gets executed. Also, I don’t think you should recreate another class using the same name as the original, that might cause problems - I guess.

I, of course, am only giving you a vague possible resolution. I don’t think I’m taking everything into proper account.

1 Like

'VIEW3D_HT_tool_header(Header)' is the very first class from space_view3d.py (Blender 2.80, using a very recent version)
I already tried in someway a register/unregister method but I ended up with more issues but I’ll try again in a different way, maybe it’s how I’m applying it.
Thanks for the help provided, later I’ll answer if I managed to solve it

Well, if you’re just trying to change VIEW3D_HT_tool_header then I don’t understand why anything should have to intersect. The header should have plenty of room - it can slide using the middle mouse button.

Also, I imagine you’ve already imported VIEW3D_HT_tool_header but, if not, then that must be done in order to work right.

I’ll think about your problem some more, and if I think of any other possible helps I’ll post.

Sorry, I couldn’t help.

1 Like

There are some fixed elements in the new tool header so they don’t slide and stays over other elements… So I want it cleaner as possible and without sliding to be able to access other elements.

As you suggested, I tried (again) register/unregister the original class, VIEW3D_HT_tool_header I unregister it at the end of the def register of the addon and register it again after my custom UI class, at the very bottom and outside the SCULPT condition, so no condition, because otherwise and idk why the tool header for the other modes is not showing. That way is mid-ok cause the addon ui is now showing before the built-in ui, but I have the same problem of the built-in UI showing up (for future I wanted to add like a toggle to switch between) plus some constantly warnings/errors all the time… __init__.py", line 451, in draw register_class(VIEW3D_HT_tool_header ValueError: register_class(...) already registered as a subclass. but luckily it manage to slide now that overlay elements, no solution at all in the way I wished for but probably the best thing I can do actually. Thank you @J_B !!! :grin:

This is a screenshot showing the issues of the coexistence between the addon ui and the original ui

So with the overwrite this issue disappeared cause I destroyed the entire built-in tool header. But this is how I want it to look like

And with this new update of the register/unregister looks like this

plus the warning/error:
__init__.py", line 450, in draw register_class(VIEW3D_HT_tool_header) ValueError: register_class(...): already registered as a subclass