Buttons, panels, and menus. In this chapter of Scripting for Artists, Sybren shows the basics of creating your own user interface in Blender.
- Finding existing UI code: 00:55
- Ingredients of a Panel: 01:42
- Different import styles: 03:00
- Monkey Grid panel: 04:09
- Adding operator buttons: 06:03
- Basic layout tweaks: 09:21
- Adding scene and object properties: 10:20
- Conditional drawing: 13:26
- Adding operators to menus: 15:30
Join to comment publicly.
6 comments
Hi sybren, thanks for your tutorial! I just get confused at around 9:00, about the "Big Grid" and "Small Grid". The Sample's code is like:
But how can a single variable
props
work for two buttons? The fact is when I'm running this script on Blender 4.1, the Small Grid button didn't show up. So is there anything I've missed? Hope for explain.Sorry, I just found that I made mistake, typing
props.size
toprops.dize
. And script quit silently from that line. After correcting it, the small button showed up. But I'm still can't understand my origin question, why a singleprops
can work for two buttons. Maybe there's no single words can explain why, still hope for explaination.Thanks for the tutorial. But how do I make the x, y and size values be defined by user input in the panel? I tried:
The fields with the default paramaters show up in the panel, but I'm not able to change them. My guess is that I have to work with variables. I tried a couple of things, but I failed. Anyone?
*@Tijm Lanjouw* You have to define the user-editable properties somewhere else. If they are to be saved within the blend file, you typically would add them to
bpy.types.Scene
. If they are temporary, you typically add them tobpy.types.WindowManager
. You can then use them to assign for exampleprops.count_x = context.scene.my_monkey_grid_count_x
.You cannot use operator properties with
layout.prop()
.@Sybren A. Stüvel For those searching, this is explained better in chapter 11 ;)
A very clear and resourceful video. Even after making 30+ addons I learned a few things. e.g: I will certainly use columns starting now ;), thanks Doc.