1
$\begingroup$

I'm a beginner at python language. I browsed the blender python API documentation, I didn't understand how to use it or benefit from it to know more about blender functions and classes. For example: I learned from a tutorial that this function is used to link an object to a collection:

bpy.context.collection.objects.link(obj)

How do I use the documentation to know more details about this function, for example, how to link the object to a specific collection?

$\endgroup$
2
  • 2
    $\begingroup$ I'd recommend to browse concretly the data structures using the Python console in Blender and the autocompletion (tab key) in // of reading the doc. For instance you'll see that a collection can have children which are collections themselves. $\endgroup$
    – lemon
    Mar 18, 2020 at 11:47
  • $\begingroup$ Personally I think the Blender API documentation is some of the worst API documentation I've ever seen. I can't find answers to even basic questions in the documentation like, "How do I create a light and add it to the scene?". I have yet to find any answer to any question I have on the Blender API documentation, every answer I have found has been via Google and stackexchange. $\endgroup$
    – Grady
    Sep 6, 2020 at 3:32

1 Answer 1

3
$\begingroup$

The most common way or method to know how to use it is actually try it. Thanks for the Python interactive console, we can do that easily with auto-complete (Tab). And for most of the function, it will provide some basic information defined in function itself (basically a tooltip). Which will showed at autocomplete phase:
enter image description here

And for the rest of it, you might need to try it yourself to know how these collection, object, mesh, vector are stored(and link) in Blender. The you can roughly guess how you link a new object to a specified collection, by experience.

Also, there is some code snippet for handy function in Blender Manual as well. You might find something that you want or some workaround solution. Then you follow those code to help you complete your task.

Yes, it will be very frustrate to learn the structure in Blender and all other application. And if you are not familiar in "Python Class", you really should to learn about it at first. It should help you to understand Blender Python in every aspect.

$\endgroup$
1
  • $\begingroup$ As brockmann mention, auto complete has been change from Control+Tab to single Tab from version 2.82. Which is much more conveniently and same as all other code editor. (Thank god) $\endgroup$
    – HikariTW
    Mar 19, 2020 at 0:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .