RenderInWindow Coordinate system

Hi,
I am trying to make a script to do some tile rendering using the RenderInWindow Command, and I cannot seem to figure out what coordinate system RenderInWindow uses.
I have tried using the final coordinates eg(0,0 640,480) however this seems to only be rendering the bottom corner. I have tried going from -render size to render size eg(-640,-480 640,480) however this seems to be cutting off the top half of the image and only rendering to 3/4 of the final height.

Thanks,
Grant

You will need to specify world coordinates (x,y,z). These will then be converted to screen coordinates for you.

For example:

x = Rhino.GetPoint("First corner of rectangle")
y = Rhino.GetPoint("Second corner of rectangle")
Call Rhino.Command("RenderInWindow " & Rhino.Pt2Str(x,,True) & Rhino.Pt2str(y))

This seems to be a really weird coordinate system to script it in. From a user perspective screen coordinates would make a lot more sense. Hopefully I can get this to work for me.

We are trying to create evenly sized regions through script which is difficult in world coordinates

You can use Rhino.XformScreenToWorld to transforms either client-area coordinates of a specified view or screen coordinates to world coordinates. The resulting coordinates are represented as a 3-D point.

Does this help?

It helps somewhat, and that is what I have been trying however it is still not the most useful coordinate system for example in our case we are wanting to be able to create regions while rhino is closed and just pass them in through script. Which is very simple in screen coordinates and difficult without creating a command in rhino that you call outside of rhino.

This also leads me to a second issue I seem to be having with this. When I run a renderInWindow command through rhino’s ui and then try the same region through the command line interface they are creating different sized regions over a similar area. For example I am trying to create a 160x480 region when I open rhino manually and use renderInWindow I get the right sized region yet when I use the command line I get a 155x497 region which is weird because my viewport is only 640x480. If you would like I can send in a minimalist example for this.

or apparently Rhino opens with different sized viewports when you open a scene through the command line…

Yes, this can be true depending on Rhino’s state (maximized, etc.) when it is closed.

If you need to ensure a particular viewport size, then script the ViewportProperties command and it’s Size option to set the pixel width and height. Then, just script the Render command (instead of RenderInWindow).

Hi Dale,

I am wondering if there is a similar method in RhinoCommon?

I want to change Rhino.UI.MouseCursor.Location(screen coordinate system) to WorldXY.

Thx

How about this?

public bool ConvertScreenPointToWorldPoint(
  RhinoView view, 
  System.Drawing.Point screenPoint, 
  out Point3d worldPoint
  )
{
  var rc = false;
  worldPoint = Point3d.Unset;
  if (null != view)
  {
    var xform = view.ActiveViewport.GetTransform(
      CoordinateSystem.Screen, 
      CoordinateSystem.World
      );
    worldPoint = new Point3d(screenPoint.X, screenPoint.Y, 0.0);
    worldPoint.Transform(xform);
    rc = worldPoint.IsValid;
  }
  return rc;
}

– Dale