Python API for Active Tools

Now that the beta is available I really want to dig into the Python API and start working on some additional functionality.

There appears to be some good information here:

https://docs.blender.org/api/blender2.8/

https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API

The only thing that I cannot seem to find is information on creating active tools.

Am I missing some links or is this still being worked on?

2 Likes

The API for this is not available yet.

Thanks for the info. Is there a place where I can see a list of the items that still need to be documented?

We don’t have that currently. The main two things we are missing is active tools and multi-object editing.

When can we use that active tool Pyhton API?

There is no date for it currently, it should be there for 2.80 but I can’t promise anything more specific.

There is now a script that is available in the text editor space called “ui_tool_simple.py” that shows an example of how to register an active tool.

I am going to be experimenting with this but if anyone has any more information on the “bl_icon”, “bl_widget”, and “bl_keymap” properties please let me know. Thanks.

1 Like

I’m looking for info on the same. Is it possible to reuse widgets from existing tools or inherit from existing tools?

Yes you can. Tools can define which gizmo to use, and, afaik, you can add your own too.

WorkSpaceTool API looks good.
Now, I am troubled with how to specify my Addon folder in ”bl_icon” and how to create a “.dat” file.
Please let me know if you have any information.

@ Akelian has shed light on some of the available builtin gizmos at stack exchange:

1 Like

There’s a guide here on how to create the toolbar icons:

https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/UI_DESIGN

1 Like

Thank you for the information.

I tried to create an icon but it seems that some information is missing.
“blender_icons_geom.py” is not included in the package, but where can I get it?

It’s in the Blender source.

@ideasman42 we should probably package this stuff in a nicer way for addon developers.

2 Likes

Here are the descriptions of widget and keymap according to “your blender install directory\2.80\scripts\startup\bl_ui\space_toolsystem_common.py”
WIDGET:

    # An optional gizmo group to activate when the tool is set or None for no gizmo.

This is of the type

    bpy.types.GizmoGroup

A good example of this type can be found the Gizmo Operator Target python template.

KEYMAP:

    # Optional keymap for tool, either:
    # - A function that populates a keymaps passed in as an argument.
    # - A tuple filled with triple's of:
    #   ``(operator_id, operator_properties, keymap_item_args)``.
    #
    # Warning: currently 'from_dict' this is a list of one item,
    # so internally we can swap the keymap function for the keymap it's self.
    # This isn't very nice and may change, tool definitions shouldn't care about this.

Thank you very much! I was able to create my own icon.
This was a lot of work, so I think it would be nice to have a simpler way.

By the way, I put it in “datafiles/icons” folder and I can specify it with “bl_icon”, but I do not know how to specify the my add-on folder.
Does anyone have any information about this?

Hi, did you figure this out? I’m doing the same thing but I don’t how to read the .dat from my addon folder either.

Or maybe someone else knows? Or is it even possible currently? If not, I guess my addon needs to copy the icon into the icons folder automatically.

It seems that the add-on icon path can be specified in ”bl_icon".

For example:
bl_icon = os.path.join (os.path.dirname (__ file__), “addon.hoge_icon”)

1 Like

Thanks, that works!

I tried that before but it didn’t work then. I guess I just had some spelling mistake or something.

1 Like