# How do I enable custom gizmo display when I move?

I am currently working on a custom gizmo for my add-on. I have a function to move the object (transform.translate). At this point my gizmo disappears and a normal trajectory line appears. How do I enable gizmo display when I move? use_draw_modal = True is not working. I'm using GIZMO_GT_arrow_3d

So this is a bit of a strange answer but having tested it there seems to be some other mechanism at play that I'm still looking into, but so you aren't chasing an answer in the wrong place, I'll share what I have found.

The gizmos don't appear to show themselves during the operation, they seem to be replaced by an operator specific gizmo until after the refresh is called.

For example, using the GIZMO_GT_arraw_3d against the transform.rotate operator replaces the arrow with a dial, as shown by this code:

def setup(self, context):
# Run an operator using the dial gizmo
ob = context.object
mpr = self.gizmos.new("GIZMO_GT_arrow_3d")
props = mpr.target_set_operator("transform.rotate")


So your gizmo is only your gizmo while nothing is happening. This seems strange and is perhaps intended behaviour, but without some serious documentation to go by this is the most I could uncover. I need to look into how gizmos and operators are linked.

Having played around some more, it appears that this behaviour only happens when you use target_set_operator, this doesn't happen with target_set_prop

There is another option here, which is to define a pair of callbacks for the gizmo by calling its target_set_handler method and telling it how to get and set the "offset" proerty of the GIZMO_GT_arrow_3d gizmo:

def setup(self, context):

arrow = self.gizmos.new("GIZMO_GT_arrow_3d")

def move_get_x():
return context.object.location.x

def move_set_x(value):
context.object.location.x = value

arrow.target_set_handler("offset", get=move_get_x, set=move_set_x)

arrow.matrix_basis = context.object.matrix_world.normalized()

self.x_gizmo = arrow

def refresh(self, context):
self.x_gizmo.matrix_basis = context.object.matrix_world.normalized()


This example demonstrates how to use a vertical arrow to modify the x location, you obvious want to do something more sensible but this can be modified easily by changing the move_get_x and move_set_x callbacks.

• thank you, I'm counting on you) – Max Derksen Aug 12 '19 at 17:27
• @MaxDerksen I hope this answer is helpful, if so don't forget to accept so others are aware that this has been resolved. – Moog Aug 14 '19 at 6:52
• thanks, the last part solves the problem, of course is to Tinker with it, but this is the same approach I think is correct. – Max Derksen Aug 14 '19 at 11:58