Hey I’m after some advice. I’m new to coding and trying to learn python in blender, making progress, but one of things that I’ve found confusing is how to find the commands / code I’m after…
For example. I was looking for a way to list all the scenes in a blender file and thankfully stumbled across an exact code example https://docs.blender.org/api/current/bpy.data.html
# print all scene names in a list
print(bpy.data.scenes.keys())
But how/where would you normally figure that out? ie. that .keys() is the right command to use? I can’t see it listed in the API and when I hover over the ‘scenes’ with python tool tips on I only see bpy.data.scenes[Scene].name
Any good workflow advice for finding code you’re after (besides google)?
Personally I find it useful to play around with the code autocompletion in blender’s python console.
For example, type bpy.
in the console and hit tab, and it will show a list of ways that could be completed (e.g. bpy.ops, bpy.data, etc). Choose one, and then again hit tab to show the list of options that has, and so on…
In my experience you won’t necessarily find the exact command, but I find experimenting in the console to be a good way to get a feel for which specific things I need to look up in the API or on google to find what I need.
Here’s how you’d get to that through the link you provided, it’s easier to provide pictures than try to type it out, just click where you see the pointer cursor: