5 ms·
Definitely, prefer using bpy.data objects whenever you can. IIRC there were a few things I wanted to do that only seemed possible through bpy.ops, for example r
by daenz 5y ago
Definitely, prefer using bpy.data objects whenever you can. IIRC there were a few things I wanted to do that only seemed possible through bpy.ops, for example recursively duplicating a collection. In the UI, this calls bpy.ops.outliner.collection_duplicate() and requires the Outliner editor to exist and be active. There are workarounds, but they aren't pretty.
- Etherlord87 5y agoAnother example is changing modifier order - you can do that only with operators.
- UncleEntity 5y agoBack when I was poking at the python API a lot of what I did was figure out how the operator did it and either wrap the function it called as a method on the object or write a simple C function wrapper and expose that to python. Most things that people needed just needed someone to spend a little time on. I think it was the outliner (the part where you edit the keyframes?) where the underlying design made the python API an absolute trainwreck. I spent a bunch of time on that and it was just bad, the best that could be done was to expose it and let people who were sufficiently motivated dig around and figure out how all the pieces interacted because it wasn’t at all obvious. Horrible design from the python side… Anyhoo, sounds like someone just needs to add a collection.duplicate() or .clone() method — whichever is more pythonic.