Hello, I want to get the position of the mouse, but I don’t want to get the mouse in the ‘event’ of ‘bpy. Types. Operator’. I want to get the mouse without entering the mode. Is there any better way
as far as I’m aware it’s not possible to get the mouse position without an event. knowing that it’s just python you’re running on- you can use pretty much any method you like- you’ll just have to convert the screen coordinates into relevant data you can use in Blender (relative to region coordinates, etc).
@sybren I’m not sure what OP is trying to do, but one example I’ve used this for in the past is knowing what the precise mouse position was at the time a menu was invoked (by hijacking the poll function), so operators can raycast from the ‘position of intent’ rather than wherever the menu button happened to appear on the screen.
Sorry, I didn’t make it clear. I want to draw the grid in the 3D view and obtain the mouse position to locate the mouse position in the 3D view. Just like the tool ‘add Cube’, I can draw the grid in the mouse position, but it doesn’t enter the mode
I tried to use the external library ‘pyautogui’ to get the position of the mouse in the window, but the obtained value is based on the screen, not on the 3D view