I'm building a color ID baker and I'd like to access the margin slider on my addon. I've looked in the API and gone through numerous attempts, but I can't quite figure out the python command to change it, much less implement it elsewhere.
The bake settings are a collection of settings available in
So, to access the Margin you would do:
bpy.context.scene.render.bake.margin = 16
This was a little tricky to find, but there were a few hints.
- Hovering over the Margin property showed the tooltip, which revealed that the bake options were going to be in the Scene's properties.
- Baking is linked to rendering, which made me think to look under the
The best way to explore the Api is via blender's Python Console editor and use Autocomplete to see the available properties of a given class, e.g. typing
bpy.context.scene. and pressing Ctrl+Space will reveal:
>>> bpy.context.scene. NWBusyDrawing NWLazySource NWLazyTarget NWSourceSocket active_clip active_layer alembic_export( animation_data animation_data_clear( animation_data_create( appended_header as_pointer( audio_distance_model audio_doppler_factor audio_doppler_speed audio_volume etc...... etc.... etc..
I ran into this same problem and tried Ray's above method, but no matter which parameters I supplied, i.e. 8 px vs 16 px, the resulting UV map showed no difference.
After a lot of tinkering I found that the proper line to access the Margin property is:
bpy.data.scenes["Scene"].render.bake_margin = 8