[Bf-python] Python API proposals

Campbell Barton ideasman42 at gmail.com
Fri Nov 25 05:45:18 CET 2011


On Thu, Nov 24, 2011 at 8:37 AM, Dima Glibitsky <dima.glib at gmail.com> wrote:
> Thanks for the detailed answer, I'll explain my motivation.
>
> In my cursor script, there are cases which, I think, don't really fit
> into Scene/Screen storage model as it is now:
> - Cursor history. I guess, logically it should be separate for each
> scene, but currently I can't do this -- Undo/Redo would mess it up.
> - Bookmarked locations. By design, these should not belong to screen
> or scene (in this concern, they are similar to images). However,
> operations on them should be, logically, undoable.
> - Some visualization settings which should, logically, belong to User
> Preferences.

I don't think this is a common enough case to warrant designing
blender around it, however it is reasonable that you might want to
hold a reference to a datablock (scene for example), that survives an
undo.

A while ago worked on a python branch that didnt end up being merged,
but python ID references worked across undo, I'll look at making a
patch to trunk to support it again (Ton really didn't like ID's
holding references to PyObject's this, so no guarantee it will get
in).
- added to my todo list - http://wiki.blender.org/index.php/User:Ideasman42#TODO

> A bit off-topic, but related: currently almost every operation results
> in Undo history modification, even though they shouldn't behave like
> that -- e.g. just changing 3D-view shading mode can overwrite all the
> undone meaningful scene/mesh modifications with one useless action
> (which wouldn't even change shading mode back when you press Undo).
> I suggest that all (at least, many of) visualization/tool settings
> shouldn't be undoable (take GIMP, for example) ;-)

This was cleaned up recently in trunk view shading or edits on the
preferences won't call undo pushes, let us know if you find any others
that shouldn't be there.

> P.S.
> Another off-topic: are there any plans for the nearest releases to
> make TextEditor's undo history separate? Please forgive my curiosity
> :)

Yes, tho this is more of a long term todo.

>
> On Wed, Nov 23, 2011 at 3:22 PM, Campbell Barton <ideasman42 at gmail.com> wrote:
>> currently blender doesnt really have a way to store global data in a
>> blend file... data is attached to a scene/screen normally, why do you
>> need this?
>>
>> Not what you are asking for but related, IMHO we should have a way to
>> deal with user preferences for addons (or just any script).
>>
>> I plan to add at some stage and probably isn't all that hard - just
>> need to add the ability to have user preference define new property
>> types like we have now for IDs.
>>
>> While - bpy.data.global_preferences, could be added, Im not convinced
>> we need it when we have scene properties and user preferences (albeit
>> not for py scripts yet).
>>
>> The difference is that you have to save user preferences explicitly so
>> the data wont necessarily be available across sessions.
>>
>> Regarding scenes for settings - that a scene is renamed shouldn't
>> matter since you deal with the active scene (scenes store tool
>> settings for example and renaming scenes isnt an issue), so guessing
>> that your using a scene to store something which you in fact shouldn't
>> be stored there.
>>
>> If you want you can always pickle any script runtime data and store in
>> the blender user dir, and manage on your own.
>>
>> Interested to know how you intend to use this.
>>
>> - Campbell
>>
>> On Thu, Nov 24, 2011 at 12:01 AM, Dima Glibitsky <dima.glib at gmail.com> wrote:
>>> Hi, yet another proposal:
>>>
>>> Some scripts need to store their global settings with .blend file, but
>>> currently there is no way to do it reliably (properties added to
>>> WindowManager are not saved, and properties added to Screen can become
>>> inaccessible if the screen is renamed or deleted).
>>>
>>> - It would be a good practice to have data storage specifically for
>>> this purpose, e.g. bpy.data.global_preferences.
>>> - Also, it might be useful to have two types of such storage: one
>>> modifications to which are tracked in Undo history, and one which
>>> lives outside of Undo.
>>> - Perhaps it was already requested, but it would be nice if there was
>>> a tab in UserPreferences, or maybe a separate space type, devoted to
>>> the addons' preferences (this could lessen the clutter in the main GUI
>>> by moving rarely used settings to Prefernces).
>>> _______________________________________________
>>> Bf-python mailing list
>>> Bf-python at blender.org
>>> http://lists.blender.org/mailman/listinfo/bf-python
>>>
>> _______________________________________________
>> Bf-python mailing list
>> Bf-python at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-python
>>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>



-- 
- Campbell



More information about the Bf-python mailing list