is there a way to expand or crop a detailed - perspective - view in layout?
I cant figure out how to do this simple task.
I have a perspective view which shows a part of a model in a certain view-angle.
When I put this detail-view onto a layout because I look at it from below the shown geometry is more on the upper part of the picture-frame.
Now I want to rearrange it on the layout so that it sits in the middle and want to expand the upper edge of the detail-view to my border and crop the bottom part to the border - simple as that.
But when I do this the view scales in size.
as a workarround I now had to create a hatch with the same color as the background of the viewport-mode add it on top of the layout and make a white border-hatch arround the image so that the background of the viewport-mode does not show till the bottom of the layout.
You can click on the detail view boundary and turn the control points on. Does that help?
After you have the detail view sized and positioned, you can activate the view so that you can position the camera frustum per say to view your 3D model however you want, I think.
I’m pretty sure the axonometric angle shouldn’t be the culprit here. But I have seen some bugs earlier this year with things like grid and background color. It’s possible both problems were fixed, but I haven’t verified.
You can set the display mode of the detail view to embody the background characteristics you’d like to see.
Although I have seen bugs before relative to that, and haven’t tested it lately.
PS: the display mode of the detail-view IS set to the red background but it only shows when I open (double click) the detail-view. When its closed (locked) its plain white like in the first picture - its the same display-mode
And I’m not sure what display mode you’re using on your end, but you may want to upload that if you can, so others can test that specific version too.
Interesting. Not sure if there’s a way to map the angles into the camera frustum or something.
Here is a script you can use to crop a perspective detail view. It adjusts the camera target and lens length to the appropriate values to best match the previous. (There will be slight differences if the new center of the detail is different from the old center, but it will try to match approximately.)
import Rhino
from Rhino.Geometry import Vector3d
import rhinoscriptsyntax as rs
def crop_perspective_view():
# user input
detail = rs.GetObject("Detail to crop", filter=32768, preselect=True)
if not detail:
print("Cancel")
return
rect = rs.GetRectangle(mode=1)
if not rect:
print("Cancel")
return
rs.EnableRedraw(False)
# resize detail
rs.EnableObjectGrips(detail)
rs.SelectObjectGrips(detail)
grips = rs.SelectedObjectGrips(detail)
grips = [grips[i] for i in (2,6)]
grip_pts = [rs.ObjectGripLocation(detail, grip) for grip in grips]
detail_center = (grip_pts[0] + grip_pts[1])/2
detail_size = min(grip_pts[1].X - grip_pts[0].X, grip_pts[1].Y - grip_pts[0].Y)
rect_center = (rect[0] + rect[2])/2
rect_size = min(rect[0].DistanceTo(rect[1]), rect[1].DistanceTo(rect[2]))
offset_x = rect_center.X - detail_center.X
offset_y = rect_center.Y - detail_center.Y
new_points = [rect[i] for i in (0,2)]
for grip, new_point in zip(grips, new_points):
rs.ObjectGripLocation(detail, grip, new_point)
rs.EnableObjectGrips(detail, False)
# model space
layout = rs.CurrentView(return_name=False)
rs.CurrentDetail(layout, detail)
if rs.ViewProjection() == 2:
old_camera, old_target = rs.ViewCameraTarget()
old_lens = rs.ViewCameraLens()
old_depth = old_camera.DistanceTo(old_target)
old_size = old_depth*24/old_lens
up = rs.ViewCameraUp()
normal = Vector3d(old_camera - old_target)
xaxis = Vector3d.CrossProduct(up, normal)
old_plane = rs.PlaneFromNormal(old_target, normal, xaxis)
# calculate updates
target_delta = old_plane.XAxis*offset_x + old_plane.YAxis*offset_y
target_delta *= old_size/detail_size
new_camera = old_camera
new_target = old_target + target_delta
new_lens = old_lens*detail_size/rect_size
# apply updates
previous_lock = rs.DetailLock(detail, False)
rs.ViewCameraTarget(camera=new_camera, target=new_target)
rs.ViewCameraLens(length=new_lens)
rs.DetailLock(detail, previous_lock)
rs.CurrentDetail(layout, layout)
rs.SelectObject(detail)
rs.EnableRedraw(True)
if __name__ == "__main__":
crop_perspective_view()
As for why it’s not trivial to crop perspective views, consider this view with an array of spheres. I’ve increased the lens length to exaggerate the effect, but notice how the spheres in the corners of the viewport are distorted. This is caused by the projection of the camera onto a flat screen. If you were to crop the viewport to the red rectangle, the entire view would have to be skewed diagonally to match the scene in the original, larger viewport. This is unavoidable for any crop that doesn’t keep the center of the viewport constant.
hmm ok I think I kind of understand what you mean - I just can’t get rid of thinking it is “just” an expansion of the viewport to the cropped side - like changing a window size by not interfering with its content.