How can I get the X Y coordinates of the canvas based on the window view?
For example, I want to see where on the GH Canvas I’m looking at. Where are my window’s corners and center point in Grasshopper Coordinates?
Using “var thisCanvas = Grasshopper.Instances.ActiveCanvas” I can access the GH_Canvas but it has the XY bounds in Windows Monitor Coordinates, and not in Grasshopper Canvas Coordinates.
I guess the GH_Viewport has these coordinates, but I don’t know how to access the current (active) Canvas GH_Viewport. GH_Viewport Properties (rhino3d.com)
the Grasshopper.Instances.ActiveCanvas object has a property named “Viewport”
so it’s as easy as this if anyone may be interested in taking a look at it:
var thisCanvas = Grasshopper.Instances.ActiveCanvas;
var thisCanvasViewPort = thisCanvas.Viewport;
var visRg = thisCanvasViewPort.VisibleRegion;
var coords1 = (visRg.X + visRg.Width);
var coords2 = (visRg.Y + visRg.Height);
var viewPortCorners = visRg.X + “,” + visRg.Y + " To " + coords1 + “,” + coords2;