![]() ![]() You can also use the mouse roller to enlarge/shrink the box size. Move the box and resize it to enclose the area you want to capture.Run the script and then resize the box in order for it to get the right scale factor.Go to bottom of the script file and change the storage location to be appropriate for your machine.My example does capture the size (of the rectangle) in pixels 1 to 1. To get higher resolution you need to multiply width and height with the same factor. That’s why i use the width and height from the viewport which is then cropped to the rectangle size. It makes no sense to enter Width and Hight as shown in your GH definition. One remark about your first post: If you want to define the area to capture from a rectangle, you will likely want to preserve the proportion of the rectangle. You can use the converted 2d points in the SetWindowRect function and just copy the rest of the first example code below it if you want to save. using 2 corner points (3d) of a polyline rectangle. The second is not meant as a complete script which saves an image but demonstrates how to obtain Point2d from Point3d, eg. The first example seems to work fine here using Rhino 7 (Windows), either in views using planar or perspective viewport projection. The former saves an image that doesn’t match the viewport I was only able to capture higher sizes my multiplying the size and it does not alias. If file: if you could please take a look here? The resolution in dpi always seems 72, regardless of the value used. Settings = (view, size, 72)īitmap = (settings)įile = rs.SaveFileName ("Save", "PNG Files (*.png)|*.png||") ![]() P1 = 2d(rect.X + rect.Width, rect.Y + rect.Height) Below is a quick example which seems to capture the picked area (try this from the EditPythonScript dialog): import Rhino Hi not sure but i think you must pass Point2d to SetWindowRect for more accuracy. A workaround I found is to add a slight offset (proportional to the chosen resolution) to the points defining the print area. One thing that still bothers me is the presence of small margins all around the drawing, as if it was impossible to entirely fill the selected frame ( WindowRect). Settings = rd.ViewCaptureSettings(view, size, 300) #view, size, dpiīitmap = rd.ViewCapture.CaptureToBitmap(settings) # Set resolution to chosen scaling factor P2 = rg.Point3d(max(px) - offx, max(py) - offy, 0) P1 = rg.Point3d(min(px) + offx, min(py) + offy, 0) # Construct the points that will set the print area # Get x and y coordinates of frame vertices After numerous trial and errors I came up with the following script that makes use of the SetWindowRect method : import Rhino.Geometry as rg ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |