ddg.visualization.blender.props module
- ddg.visualization.blender.props.add_props_with_callback_from_constructors(callback: Callable[[...], Any], positional_labels_constructors: dict[str, Callable[..., Any]], keyword_labels_constructors: dict[str, Callable[..., Any]]) None[source]
A more advanced version of
add_props_with_callback().Unlike
add_props_with_callback(), this function doesn’t infer what kind of Blender property to add. Instead, property constructors must be explicitly specified, which allows for control over the minimum and maximum value, step sizes and other property types.- Parameters:
- callbackCallable
This function is called whenever the properties’ value change.
- positional_labels_constructorsdict[str, Callable[…, Any]]
The keys are the labels of the properties. The values are Blender property constructors whose values will be passed to
callbackas positional arguments.- keyword_labels_constructorsdict[str, Callable[…, Any]]
The keys are the labels of the properties. The values are Blender property constructors whose values will be passed to
callbackas keyword arguments.
- Raises:
- ValueError
If the labels aren’t unique.
See also
Examples
See Finer Control over Properties in the user’s guide.
- ddg.visualization.blender.props.add_props_with_callback(callback: Callable[[...], Any], arg_labels: Sequence[str], *default_args: Any, **default_kwargs: Any) None[source]
Add Blender properties with a callback.
- Parameters:
- callbackCallable
This function is called whenever the properties’ value change.
- arg_labelsSequence[str]
Labels for the properties. The number of labels must equal the number of positional arguments of callback.
- *default_args
Default positional arguments for callback
- *default_kwargs
Default keyword arguments for callback
- Raises:
- ValueError
If the length of
arg_labelsisn’t equal to the number of positional arguments ofcallback.
Examples
See Animating ddg Objects in the user’s guide.
- ddg.visualization.blender.props.overwrite_callback(collection_name: str, blender_objects: Callable[[P], Sequence[Any]]) Callable[[P], None][source]
Overwrite existing objects.
The returned function will either - link new Blender objects if the collection doesn’t exist or is empty and otherwise - overwrite the
dataof existing Blender objects in the collection- Parameters:
- collectionstr
Name of a Blender collection
- blender_objectsCallable
Returns a sequence of unlinked Blender objects
- Returns:
- Callable
- ddg.visualization.blender.props.hide_callback(collection_name: str, blender_objects: Callable[[P], Sequence[Any]]) Callable[[P], None][source]
Hide old objects before displaying new objects.
The returned function hides every object in the collection and then displays objects computed by
blender_objects. It creates subcollections for each tuple of properties/parameters.It is possible to delete the parent collection or any number of subcollections; they are recreated when necessary.
- Parameters:
- collectionstr
Name of a Blender collection
- blender_objectsCallable
Returns a sequence of unlinked Blender objects
- Returns:
- Callable
- ddg.visualization.blender.props.clear_callback(collection_name: str, blender_objects: Callable[[P], Sequence[Any]]) Callable[[P], None][source]
Clear collection before linking new objects.
The returned function unlinks every object in the collection and then links new objects computed by
blender_objects.- Parameters:
- collectionstr
Name of a Blender collection
- blender_objectsCallable
Returns a sequence of unlinked Blender objects
- Returns:
- Callable
- ddg.visualization.blender.props.add_panel(prop_names: Sequence[str], text: str = '', panel_label: str = 'DDG Panel', idname: str = 'VIEW3D_PT_DDG', category: str = 'DDG')[source]
Create a Blender panel in the 3DViewport containing the properties.
- Parameters:
- prop_namesSequence of str
The properties’ names to be added to the panel.
- textstr
Text to be added at the beginning of the panel.
- panel_labelstr
Text used as the visible title of the panel.
- idnamestr
Name used internally to identify the panel. Must begin with
VIEW3D_PT_.- categorystr
String used as the name of the tab.
- Raises:
- ValueError
If
idnamedoes not start withVIEW3D_PT_.
- ddg.visualization.blender.props.update_func(callback: Callable[[...], Any], arg_names: Sequence[str], kwarg_names: Sequence[str]) Callable[[Any, Any], None][source]
Turn a function into a property update function.
- Parameters:
- callbackCallable
Callable which will be called when the properties value change.
- arg_namesSequence of str
The names of the properties corresponding to positional arguments of callback.
- arg_namesSequence of str
The names of the properties corresponding to keyword arguments of callback.
- Returns:
- updateCallable
A function to be used in e.g.
bpy.props.IntProperty(update=update).
- ddg.visualization.blender.props.set_prop_if_not_set(blender_id: Any, prop: str) None[source]
Set
blender_id.proptovalueif notblender_id.is_property_set(prop).This is a no-op when executed after loading from a .blend file that previously set
prop.- Parameters:
- blender_idAny
- propstr
- ddg.visualization.blender.props.save_props(file_name, bstruct, props)[source]
Save properties of a Blender object to a file.
- Parameters:
- file_namestr
The name of the file to save the props to.
- bstructbpy_struct
The Blender object whose properties should be saved.
- propsA list of str
Each string is the name of a property.
- ddg.visualization.blender.props.load_props(file_name, bstruct)[source]
Load the properties from and set them to a Blender object.
Assumes that the file was generated with
ddg.visualization.blender.props.save_props.- Parameters:
- file_namestr
The name of the file from which to load the props.
- bstructbpy_struct
The Blender object whose properties should be set.