[Bf-python] Extra functionality proposals

Dima Glibitsky dima.glib at gmail.com
Sat Nov 19 08:56:40 CET 2011


I propose to add the following functionalities:

* A variant of object.ray_cast that returns all intersections, not
just the closest one.
Examples where this can be beneficial:
- determining whether a point is inside or outside a mesh
- determining thickness/gaps in the given direction
- filter intersection results (e.g. consider only frontfacing
polygons, ignore polygons with transparent material, etc.)

* A mechanism to temporarily freeze undo history.
Currently there is no way for scripts to get up-to-date mesh data
while it is in editmode. Scripts can toggle editmode, but that has a
nasty consequence of modifying the undo history... The situation may
change with the arrival of BMesh, but, even then, freezing history
could still be useful for some other cases I don't know of.
On the Python level, I suggest it to be implemented as a context manager:
[CODE]
with bpy.utils.freeze_undo_history():
    # ... Do some sneaky operations. Don't forget to return everything
to where it was!
# At this point, undo history is the same it was before freeze_undo_history().
[/CODE]

* UILayout method to display "fake" ID datablock selectors.
This would be useful for the situations when a script wants to present
a custom dynamic list of selectable (and, possibly, renamable)
elements:
- choosing an object from the custom-filtered list (e.g. from objects
which have custom property that satisfies some condition)
- defining and working with custom libraries of domain-specific
objects (operator presets, game object templates, bookmarked cursor
positions, etc.)

Example signature:
UILayout.prop_collection_selector(data, property, name_property,
search_data, search_property, search_icon='NONE', add_op=None,
add_icon=None, remove_op=None, remove_icon=None, allow_rename=True)

data -- object from which to take collection
property -- identifier of the corresponding CollectionProperty member
name_property -- identifier of item's StringProperty, which has the
semantics of unique item's name
search_data -- object that stores active (selected) collection element
search_property -- identifier of the corresponding StringProperty
member; has the semantics of active element's name
search_icon -- icon for drop-down selector
add_op -- operator for adding items to collection
add_icon -- add_op icon
remove_op -- operator for removing items from collection
remove_icon -- add_op icon
allow_rename -- if False, the name won't be editable (like in Enum selector)

Also, any conflicting names should be automatically renamed, like
everywhere else in Blender.

Another solution is to introduce a special kind of Property for such
cases (e.g. CustomIDBlockProperty).

------------------------
dairin0d



More information about the Bf-python mailing list