Python API for Active Tools

#1

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?

1 Like
How to implement custom gizmos?
#2

The API for this is not available yet.

#3

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

#4

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

#5

When can we use that active tool Pyhton API?

#6

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

#7

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
#8

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

#9

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

#10

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.

#11

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

#12

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
#13

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?

#14

It’s in the Blender source.

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

2 Likes
#15

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.
#16

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?