On 14/06/2015 at 13:56, xxxxxxxx wrote:
I am trying to get the Mouseposition in the Viewport when I run a Script. Is this possible without making a Tool-Plugin? I tried this code and it does not return anything.
import c4d from c4d import gui def main() : bc = c4d.BaseContainer() c4d.gui.GetInputState(c4d.BFM_INPUT_MOUSE,c4d.BFM_INPUT_X,bc) mouse_x = bc[c4d.BFM_INPUT_X] print mouse_x if __name__=='__main__': main()
On 14/06/2015 at 14:02, xxxxxxxx wrote:
Sorry....I was sitting on this for hours now....and a minute after posting I found the solution:
But I have another Issued with mouse coordinates...now I get the Coordinates of the mouse in the complete C4D-Window. But I need the coordinates of the mouse inside the viewport. Do you have a solution?
What I need is the Pixel-Vallue of the left uper corner of the Viewport in my Layout.
On 15/06/2015 at 03:31, xxxxxxxx wrote:
a script might not be the right place to do such user interaction. A script is meant to include some commands that are executed and then the script is finished.
Getting the correct coordinates you might need to use functions like Screen2Local(). Such functions are available in GUI related classes like GeDialog and GeUserArea but also EditorWindow. You can get the EditorWindow from the BaseDraw using GetEditorWindow() and the BaseDraw from the document using GetBaseDraw().
On 15/06/2015 at 04:03, xxxxxxxx wrote:
Thanks Sebastian. That worked for me. But instead I used Global2Local() which gives the Coordinates relative to the C4D Window.