EDIT
I've moved a different way. Using ray_cast to get face location and normal. Applying the normal to the empty vector is now my challenge :)
EDIT
I'm writing an addon that I need to interactively move an empty and have it snap and align to any face the mouse runs over, exactly like the move
command with snapping active, I'd also like the user to be able to manipulate the viewport during this but bpy.ops.transform.translate("INVOKE_DEFAULT")
does not allow this behavior.
I thought I could run bpy.ops.transform.translate("INVOKE_DEFAULT")
then kill it on a MIDDLEMOUSE
PRESS
event in my modal (like when pressing ESC
), then start it again on a MIDDLEMOUSE
RELEASE
event. 2 problems with this, I can't find a way to terminate the translate operator from code (despite many hours searching) and if it's started from within my modal the events don't seem to get passed through anymore, I'm assuming because it runs as a modal and running modals from modals is not a good idea.
Is there a way to force bpy.ops.transform.translate("INVOKE_DEFAULT")
to allow viewport manipulation explicitly? Or would I have to make my own operator? (no idea even where to start with the snapping bit)
How do you terminate a bpy.ops
(that's running as a modal) from code?
Is there another way?
return {'PASS_THROUGH'}
in operator when pan/rotate/scale viewport, otherwisereturn {'RUNNING_MODAL'}
blender.stackexchange.com/questions/259016/… $\endgroup$bpy.ops.transform.translate("INVOKE_DEFAULT")
from within my modal, the events stop being passed through $\endgroup$bpy.ops.transform.translate
modal is running, it can't run another operator modal until it finish. Also should be avoid to useops
in operator. $\endgroup$