Docs
Download

Viewport Draw

Draw your own graphics into the 3D Viewport and other editors.

A Viewport Draw node runs its Draw flow every time an editor redraws. Connect Draw nodes to that flow and they appear in the editor, in every editor of that type, for as long as the add-on is enabled.

The active object outlined in blue with its name drawn above it, next to the nodes

Drawing in the 3D Viewport

The example above has two Viewport Draw nodes, because it draws in two ways:

Outline draws In the Scene: points are 3D locations, like the object's vertices. Add a Viewport Draw (Add › Drawing), keep 3D Viewport and In the Scene, and turn on In Front so the lines show through the object.

Connect a Draw Object to its Draw output. Its Object is a Blender Data node with the path active_object. Pick a Color and set Width to 3.

Name draws On Top: positions are pixels of the editor, from its bottom left corner. Add a second Viewport Draw, set it to On Top, and connect a Draw Text with Center alignment and Shadow.

The text goes where the object is on the screen. active_object.location goes through a Python Expression (location + mathutils.Vector((0, 0, 1.6)), a point above the object) into Location to Screen, whose Position is the text's Position. The text's Text is active_object.name.

Select another object and the outline and name follow it: the viewport redraws when the selection changes, and the flow runs again with the new active object.

Settings

Setting
Editor3D Viewport, Image Editor, Node Editor, Video Sequencer or Movie Clip Editor. The flow draws in every open editor of this type
In the SceneDraws in the editor's own space: 3D locations in Blender units in the 3D Viewport, hidden behind objects that are in front of them
On TopDraws in pixels of the editor, from its bottom left corner, on top of everything
In FrontOnly for In the Scene in the 3D Viewport: draws in front of objects instead of being hidden by them
Enabled (input)When it's off, nothing is drawn. Connect a Boolean property to let users turn the drawing on and off

Which Draw nodes fit which mode:

In the SceneOn Top
Draw Lines, Draw Points, Draw Polygon3D locations2D pixel positions
Draw CircleCenter and radius in Blender units, facing NormalCenter and radius in pixels
Draw ObjectYesNo, its vertices are 3D locations
Draw Text, Draw Rectangle, Draw ImageNo, they're made for pixelsYes

Keeping it up to date

The flow runs whenever the editor redraws. Blender redraws the 3D Viewport when you move the view, select, or change objects, so a drawing based on the scene follows along without help.

Blender doesn't redraw for things it doesn't watch: a value changed by a timer, a variable, an add-on property shown only in a panel of another editor. After changing those, run a Redraw node with Editors set to 3D Viewport (or the editor you draw in). See Interface.

Limitations

  • The flow runs on every redraw, many times a second while the user orbits the view. Keep it light: no file reading, no loops over every object of a big scene.
  • Draw nodes only draw inside the flow of a Viewport Draw. In an operator or a panel they do nothing useful.
  • An error in the flow happens on every redraw. A path like active_object.name fails when nothing is active; put an If/Else in front of the Draw nodes, with a condition like the Python Expression obj is not None.
  • Drawing is visual only. Users can't click what you draw; for that, combine it with a modal operator that reads the mouse.