my intuition is that
active_object.data is not the right command?
Q > what is right command ? Why and how do you to detect it as right name command? for wm.context_toggle
i hope someone can help me understand by explaining since i really dont get the logic behind it i really have 0 knowledge in reading language python i just do referencing/comparing so i can understand
The access path is space_data.uv_editor.show_stretch
It’s available in SpaceUVEditor only.
I recommend to add a new keybinding to Image > UV Editor > Image Generic (so the keybinding will work while the cursor is over the sidebars too, not just the main area).
The names with uppercase letters are types (or classes in object-oriented programming). The access paths refer to instances (or objects) however. All types are available via bpy.types.*, but you can’t access the data structure instances that store the actual data here, only the blueprints. You can figure out the object hierarchies using the API docs or by fiddling around with auto-complete in the Python console.
However, I find it a bit unclear, how to “navigate” around “.” paths… windows, context, data, areas and such. It’s not so clear / self-evident where to read and where to set Blender scene data values.
Most likely have to do more reading, I’ve only done trial and error testing and googling so far. But this is how I get similar thing working:
Sami
# Access "real" active window viewports (I think)
# bpy.context.window.screen -> bpy.data.screens['Default']
# then the window has screen areas, one of which might be image/UV editor
# bpy.context.window.screen.areas[5].type -> 'IMAGE_EDITOR'
for area in bpy.context.window.screen.areas:
# if screen area is of type image editor,
# bpy.context.window.screen.areas[x].type, where x is 0-N
if area.type == 'IMAGE_EDITOR':
# then image, perplexing but true, image editor contains, "spaces"
# first of which is 'IMAGE_EDITOR', then there is 'LOGIC_EDITOR' etc
for space in area.spaces:
# and it seems: bpy.context.window.screen.areas[x].spaces[0].type
# --> 'IMAGE_EDITOR', now we got the correct "context"
if space.type == 'IMAGE_EDITOR':
# on command line, this would work:
# bpy.context.window.screen.areas[5].spaces[0].uv_editor.show_stretch
# here's a toggle code, if on > off and vice versa:
if space.uv_editor.show_stretch == True:
space.uv_editor.show_stretch = False
else:
space.uv_editor.show_stretch = True
I’m very limited on time - is there a single good tutorial / book / article where the structure of Blender bpy.* items are explained?
Is there some sort “find” for commands? like in 3ds Max, it was very helpful for learning, that you can write apropos “mesh*” and you get all the commands containing mesh…
Thanks, I think it’s API docs then - TBH, it’s more like a reference, not an introduction or tutorial about structure of Blender. As first step, it’s (at least for me) easier to check out some introduction / overview to subject, instead of browsing a references. I bet most of the needed stuff is there, but it’s very much like a phone book, information is just there. Like I mentioned, I’m limited on time and I’m not the best reader of references either, that’s why I asked.
EDIT: it seems there are some tutorial like parts there too, so I’ll check them! Thanks!
Yeah there are some tutorials and embedded examples. But when it comes to the structure, the only meaningful way is the phone book-style - there are simply too many data structures and functions.
You should check out the wiki, the examples are not that accurate and up to date, but you might understand things better.