Python Presets Experiments

July 8th, 2004 . 4 comments

Yesterday, looking back through one of my old sketchbooks, I got thinking about an old idea from a while back. With Willian Padovani Germano’s recent work on integrating Python scripts in Blender’s menus, this idea is now a lot easier to realise, so I gave it a go and made a proof-of-concept.

The idea is to create a system of presets in Blender, using Python scripts to load and save the relevant information. From a user’s perspective, one would be able to save presets for things like video/image dimensions (scenes), materials, textures, and eventually colorbands, themes, or any other data that is accesisble via Python that would be useful to re-use. A user could save a preset (which would involve Blender writing out a new Python script to disk), then share it with other users, who would just need to drop that script into a ‘presets’ folder to install it, making it show up automatically in a ‘Presets’ menu.

Scene preset experimental screenshot

(click for a larger screenshot)


Some of this functionality can already be achieved by appending datablocks from another .blend file, however this method has the following disadvantages:

  • It’s not easy to install new presets
  • It’s not easy to include new presets by default in the installation package
  • It’s not possible to append presets for things that don’t have datablocks (like themes)
  • It’s not possible to prest only some of the settings in a datablock. For example if I append a ‘Scene’ datablock, it will also import a whole bunch of other information, when all I might want to preset is the frame size and pixel aspect (perhaps for a proprietary image or video format one might be working with).

There are also additional advantages to using Python for this:

  • Values can be generated programatically, for example using random numbers, or generating values based on relationships to other Blender data
  • Presets could integrate well with other Python scripts, such as a script that applies variations on a preset to a number of other objects. Python script authors would also be able to easily copy existing code to or from presets to other scripts

The code I have working (shown in the screenshot), was relatively simple to create. Ideally, I’d rather have the presets in a proper popup menu (like the image format menu) so you can see what preset is currently selected, and somehow have it change to ‘Custom’ when the values have been manually changed. The scripts I used to make the presets in the screenshot are available here: A3, 300dpi, HDTV 1080/24p. These scripts can be run manually inside current Blender versions, but of course won’t show up in a presets menu.

Perhaps one more thing to go on the 2.35 todo list!

§ 4 Responses to Python Presets Experiments"

What's this?

You are currently reading Python Presets Experiments at Matt Ebb.

meta