0
$\begingroup$

I've been playing around with Blender's UI recently to see if I can find ways to make my workflow a bit easier, and also just for fun. My goal is to create UI buttons to change the sculpt brush. I'm very new at scripting though and don't know how to do most of this or if it's even possible.

I've looked at the api and found "active_index_set" but I don't know if that's the operator to call and if it is I don't know how to get it the parameters it needs to set the brush. I've looked at IK3d's brushes addon to see how he got the buttons to change the brush, and it looks like he used a list somehow. For what I'm doing custom this doesn't need to work with custom brushes as from what I've read so far that would complicate it a lot.

Any help would be great, even if it't just a point in the right direction.

$\endgroup$
  • $\begingroup$ Do you mean to switch brushes from a list of available brushes, or to change specific parameters of the brushes? I made a simple addon for myself where I set a toggle for switching between crease brush and scrape/peaks brush, and then another for toggling between the snake hook and the clay strips brushes. That wasn't too hard to just set the brush to the one I wanted. $\endgroup$ – Craig D Jones Nov 16 '17 at 18:31
  • $\begingroup$ All I really want to do is have a list of buttons in the toolbar to change the brush, not the parameters. Pretty much like the current brush select menu just without having to click on the current brush. Did your addon create a button or use a hotkey? $\endgroup$ – Brenticus Nov 16 '17 at 19:32
  • $\begingroup$ It uses a hotkey for the toggle, but you can make a panel with buttons if that is what you want to do. $\endgroup$ – Craig D Jones Nov 16 '17 at 19:48
  • $\begingroup$ What python operator did you use to switch the brush? $\endgroup$ – Brenticus Nov 16 '17 at 19:50
  • $\begingroup$ see below in answer form $\endgroup$ – Craig D Jones Nov 16 '17 at 19:51
1
$\begingroup$

edit: I wrote up an addon that creates a panel in the tool bar that you can drag into position above the brush panel - it polls for whether you have an object in sculpt mode or not. I made separate classes for each of the brushes so I could place them in 3 rows of 6 icons. enter image description here

$\endgroup$
  • $\begingroup$ So I tried placing the line of code you provided in a button and I get a message in the console saying Search for unknown operator 'BPY_OT_ops.paint.brush_select(sculpt_tool='BLOB')', 'bpy.ops.paint.brush_select(sculpt_tool='BLOB')', rna_uiItem0: operator missing srna 'bpy.ops.paint.brush_select(sculpt_tool='BLOB')' $\endgroup$ – Brenticus Nov 16 '17 at 21:21
  • $\begingroup$ Interesting pie menu addon for the sculpt brushes, but pulls them all in a list blendernation.com/2016/11/10/addon-sculpting-brushes-pie-menu $\endgroup$ – Craig D Jones Nov 17 '17 at 0:56
  • $\begingroup$ It looks like I may have to work with a list then. I know enough python to be able to get something to work hopefully, I just was wondering if there was a single operator I could use. The hard way it is then. $\endgroup$ – Brenticus Nov 17 '17 at 3:01
  • $\begingroup$ Edited the answer to provide a working version of what we discussed. $\endgroup$ – Craig D Jones Nov 17 '17 at 18:39
  • $\begingroup$ Thanks for walking me through that. I have a working button now, and I should be able to build off of your answer and make something work. $\endgroup$ – Brenticus Nov 17 '17 at 18:41

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.