Eto_Location on Rhino_view_point

I want the eto form position to be aligned to the top left or top right corner of the Rhino view, but I can’t seem to find the right way so far

#! python 3
import Eto.Forms as ef
import Rhino
import Eto.Drawing as ed
import scriptcontext

view = scriptcontext.doc.Views.ActiveView

rt = Rhino.UI.EtoExtensions.ToEtoScreen(view.ClientRectangle)

print(rt.Width)
print(rt.Height)
print(rt.X)
print(rt.Y)

form = ef.Form()
form.Width = 200
form.Height = 100
form.Location = ed.PointF(view.ClientRectangle.X , view.ClientRectangle.Y)
form.Show()

:backhand_index_pointing_down:This is the effect I want

:backhand_index_pointing_down:I took some inspiration from this

Viewport dimension in world view - Scripting - McNeel Forum

Hi @tom33, below seems to work over here using 2 screens:

#! python 3
import Eto.Forms as ef
import Rhino
import Eto.Drawing as ed
import scriptcontext

view = scriptcontext.doc.Views.ActiveView
rt = Rhino.UI.EtoExtensions.ToEtoScreen(view.ScreenRectangle)

form = ef.Form()
form.Width = 200
form.Height = 100
form.Location = ed.PointF(rt.X , rt.Y)
form.Show()

does it work for you too ?
_
c.

2 Likes

Thank you, this is very helpful

:globe_showing_asia_australia:

#! python 3
import Eto.Forms as ef
import Rhino
import Eto.Drawing as ed
import scriptcontext

view = scriptcontext.doc.Views.ActiveView
rt = Rhino.UI.EtoExtensions.ToEtoScreen(view.ScreenRectangle)
for i in range(4):
    form = ef.Form()
    form.Width = 200
    form.Height = 100
    if i == 1:
        form.Location = ed.PointF(rt.X, rt.Y )
        form.Title = str(i)
    elif i== 2:
        form.Location = ed.PointF(rt.X, rt.Y + rt.Height - 100)
        form.Title = str(i)
    elif i == 3:
        form.Location = ed.PointF(rt.X + rt.Width - 200, rt.Y )
        form.Title = str(i)
    elif i == 0:
        form.Location = ed.PointF(rt.X + rt.Width - 200, rt.Y + rt.Height - 100)
        form.Title = str(i)
    form.Show()

1 Like