Sketchup View origin
-
Is there a way to get Sketchup View origin relative to screen coords, through win32-api? I was searching through a bunch of functions and couldn't find it. The only good one I found was getting the origin of SU ClientArea, but not the view origin.
-
@anton_s said:
The only good one I found was getting the origin of SU ClientArea, but not the view origin.
What's the difference ?? The client area IS the viewport area ?
Maybe if you post a partial screen shot, and draw dimension lines over it, we can understand what you want.
-
I want to get the origin of view, relative to screen coordinates
-
Viewport:
classname : "AfxFrameOrView80u"
ControlType : "ControlType.Pane"
LocalizedControlType: "pane"
Name: ""
AutomationId: "59648" -
@dan rathbun said:
Viewport:
classname : "AfxFrameOrView80u"
ControlType : "ControlType.Pane"
LocalizedControlType: "pane"
Name: ""
AutomationId: "59648"Really interesting, what do i do with that?
-
@anton_s said:
Really interesting, what do i do with that?
You were asking about making system calls.
Use the info to find the view window. Once you have it's handle, you can request it's position on the screen.
see this thread for examples:
-
This script, by Matthew Scarpino, [written initially for PC's] gives the true design window on my mac.
Is this what you want, or does SU-PC draw toolbars in view?
"Automating Sketchup" by Mat is a great book...
john
view = Sketchup.active_model.active_view # Determine the size of the design window h = view.vpheight.to_s; w = view.vpwidth.to_s # Display the window dimensions puts "Window dimensions; " + w + ", " + h # Display the locations of the four corners puts "Upper left; " + view.corner(0)[0].to_s + ", " + view.corner(0)[1].to_s puts "Upper right; " + view.corner(1)[0].to_s + ", " + view.corner(1)[1].to_s puts "Bottom left; " + view.corner(2)[0].to_s + ", " + view.corner(2)[1].to_s puts "Bottom right; " + view.corner(3)[0].to_s + ", " + view.corner(3)[1].to_s # Find the location of the window's center center = view.center # Display the coordinates of the window's center puts "Center; " + center[0].to_s + ", " + center[1].to_s # Screen coordinates origin = view.screen_coords [0,0,0] puts "Origin; " + origin[0].to_f.to_s + ", " + origin[1].to_f.to_s # Find out how many units a five-pixel line should take size = view.pixels_to_model 50, [0, 0, 0] puts "Size of a 50-pixel line at the origin; " + size.to_s
-
@driven said:
This script, by Matthew Scarpino, [written initially for PC's] gives the true design window on my mac.
On Windows view.corner always return's the corners relative to view origin.
So, view.corner(0) always return's [0,0], view.corner(1)[0] gives the view.width, view.corner(2)[1] return's the height. View.center returns [width/2, height/2]. From these, there is no way of knowing the Sketchup view origin relative to actual, screen coords.What I wan't is the Windows API or some other Function(s) that would give me the hwnd to Sketchup viewport. The Windows API Function FindWindow only works at finding the handles to the windows. It can't find the handle to a panel, button, icon or other stuff, but only to a window. Since viewport is a panel, FindWindow function wouldn't be able to get its handle.
If I got the handle to viewport, I could then use GetWindowRect(hwnd, rect) method to get 1st and last corners of viewport in actual screen coordinates.
-
@dan rathbun said:
Use the info to find the view window. Once you have it's handle, you can request it's position on the screen.
Sketchup View is not a Window. I tried getting its handle by using function
FindWindow.call(className, 0)
but got 0. Then tried testing on toolbar dialogs. When toolbar was a child window (or not embeded into SU), I could get its handle, but when it was embedded into SU, FindWindow function returned 0. So, the FindWindow function doesn't works at finding handles to the panels, or 'ControllType.Pane' -
Rightnow, I get the hwnd to viewport like that:
MyTool def onMouseEnter(view) p = 0.chr*8 GetCursorPos.call(p) cp = p.unpack('ll') @viewport_hwnd = GetWindowFromPoint.call(cp[0], cp[1]) rect = 0.chr*16 GetWindowRect.call(@viewport_hwnd, rect) @viewport_rect = rect.unpack("l*") end end Sketchup.active_model.select_tool(MyTool.new)
Not a good way. I would only be able to get vieport handle, once mouse enters the view.
-
@anton_s said:
@dan rathbun said:
Use the info to find the view window. Once you have it's handle, you can request it's position on the screen.
Sketchup View is not a Window.
EVERYTHING you see on the screen, in Microsoft Windows, IS a window. A button, an edit box, a static text label, a checkbox, ... ALL of them are a window, but their style does not have a resizable frame or a caption bar, like a application window or a dialog (which are also a window.)
@anton_s said:
I tried getting its handle by using function
FindWindow.call(className, 0)
but got 0.FindWindow
does NOT find embedded child windows, only toplevel windows.You have to get the handle for the Sketchup Application window (the parent window,) then use that in
view_window_handle = FindWindowEx.call(parent_window_handle,0,"AfxFrameOrView80u",0)
Then use
GetWindowRect
using the view_window_handle. -
@dan rathbun said:
EVERYTHING you see on the screen, in Microsoft Windows, IS a window. A button, an edit box, a static text label, a checkbox, ... ALL of them are a window, but their style does not have a resizable frame or a caption bar, like a application window or a dialog (which are also a window.)
You have to get the handle for the Sketchup Application window (the parent window,) then use that in
view_window_handle = FindWindowEx.call(parent_window_handle,0,"AfxFrameOrView80u",0)
Thank you really much!!!, That should help!!!!
Advertisement