# Modify PERSPECTIVE detail-view in layout

**URL:** <https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317>\
**Category:** Rhino for Windows\
**Tags:** windows, layout, perspective, detailview\
**Created:** [November 21, 2024, 4:51pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317 "2024-11-21T16:51:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastian\_Wimmer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/sebastian_wimmer/32/769459_2.png) [@Sebastian\_Wimmer](https://discourse.mcneel.com/u/Sebastian_Wimmer)\
**Post date:** [November 21, 2024, 4:51pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/1 "2024-11-21T16:51:29Z")

</div>

good afternoon,

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.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/1/7/4/17475f142afeed6c68f58c2ae6940a2271505dcc.png)

I attached you a file - wondering why this has to be that complicated? I can crop fine when the view is isometric.

BONUS: Is there a setting that shows the background color of my viewport-mode in the layout view? Now I have to click it to see the full picture.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/f/7/a/f7a2bf4dfb3492c61b49f8e65e2ab5fb21ebce06.png)

FILE:  
[Expanding\_Cropping\_Detailview\_in\_Layout.3dm](https://discourse.mcneel.com/uploads/short-url/z8IZ4HFq8PPnvvEbdUbtPDTYYUY.3dm) (9.0 MB)

best regards,  
sebowim

---

<div class="post-metadata">

**Author:** ![lander](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/lander/32/511244_2.png) [@lander](https://discourse.mcneel.com/u/lander)\
**Post date:** [November 21, 2024, 4:59pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/2 "2024-11-21T16:59:57Z")

</div>

> [@Sebastian\_Wimmer](#):
>
> is there a way to expand or crop a detailed - perspective - view in layout?

You can click on the detail view boundary and turn the control points on. Does that help?

> [@Sebastian\_Wimmer](#):
>
> 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.

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. 🤔

> [@Sebastian\_Wimmer](#):
>
> wondering why this has to be that complicated? I can crop fine when the view is isometric.

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.

> [@Sebastian\_Wimmer](#):
>
> Is there a setting that shows the background color of my viewport-mode in the layout view?

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.

---

<div class="post-metadata">

**Author:** ![Sebastian\_Wimmer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/sebastian_wimmer/32/769459_2.png) [@Sebastian\_Wimmer](https://discourse.mcneel.com/u/Sebastian_Wimmer)\
**Post date:** [November 21, 2024, 5:27pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/3 "2024-11-21T17:27:34Z")

</div>

@lander thank you for your help but unfortunately I have already tried that and it seems it does not work.

For clarification - I want the the detail-views border (red-lines) to be were the green-lines are BUT the position of the object should not move.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/4/f/9/4f9f1cad1c2ab98d8ffde302d402b659fbbb1110.png)

The behaviour now is that when I do this it just moves everything up.

Thank you,  
sebowim

---

<div class="post-metadata">

**Author:** ![Sebastian\_Wimmer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/sebastian_wimmer/32/769459_2.png) [@Sebastian\_Wimmer](https://discourse.mcneel.com/u/Sebastian_Wimmer)\
**Post date:** [November 21, 2024, 5:29pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/4 "2024-11-21T17:29:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lander](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/lander/32/511244_2.png) [@lander](https://discourse.mcneel.com/u/lander)\
**Post date:** [November 21, 2024, 8:43pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/5 "2024-11-21T20:43:40Z")

</div>

> [@Sebastian\_Wimmer](#):
>
> I want the the detail-views border (red-lines) to be were the green-lines are BUT the position of the object should not move.
> 
> ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/4/f/9/4f9f1cad1c2ab98d8ffde302d402b659fbbb1110.png)
> 
> The behaviour now is that when I do this it just moves everything up.

hmm, k well, you might have to adjust it afterwards?

Maybe make a named view that you can use to set the specific parameters, idk.

---

<div class="post-metadata">

**Author:** ![lander](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/lander/32/511244_2.png) [@lander](https://discourse.mcneel.com/u/lander)\
**Post date:** [November 21, 2024, 8:44pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/6 "2024-11-21T20:44:41Z")

</div>

> [@Sebastian\_Wimmer](#):
>
> 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

This sounds similar to a bug I’ve seen, but I can’t remember if it was grid related only or background related also.

---

<div class="post-metadata">

**Author:** ![lander](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/lander/32/511244_2.png) [@lander](https://discourse.mcneel.com/u/lander)\
**Post date:** [November 21, 2024, 8:47pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/7 "2024-11-21T20:47:34Z")

</div>

I’m not familiar with this. Might be a new feature.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/b/7/6/b76cabcbdeea16279653df2656f7c83eb3afa479.png)

I’m not sure how much time I’ll have to test this, but this is what I see so far:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/e/3/3/e33d9516c787be5e530bdc30097ce1a541e3b41a.png)

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. 🤔

---

<div class="post-metadata">

**Author:** ![Measure](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/measure/32/651816_2.png) [@Measure](https://discourse.mcneel.com/u/Measure)\
**Post date:** [November 22, 2024, 1:53pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/8 "2024-11-22T13:53:32Z")

</div>

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.)

```auto
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()

```

---

<div class="post-metadata">

**Author:** ![Sebastian\_Wimmer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/sebastian_wimmer/32/769459_2.png) [@Sebastian\_Wimmer](https://discourse.mcneel.com/u/Sebastian_Wimmer)\
**Post date:** [November 22, 2024, 2:19pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/9 "2024-11-22T14:19:27Z")

</div>

sorry I totally forgot to upload the displaymode here you go:  
[SW\_flat1.ini](https://discourse.mcneel.com/uploads/short-url/hRgBlTlenxIZtHlxzkgWcfbTkgP.ini) (14.1 KB)

and yes your video shows exactly what I mean.

Does else know why this behaviour is like this? @wim ? feature oder bug?

thanks for helping and looking into it!

cheers,  
sebowim

---

<div class="post-metadata">

**Author:** ![Sebastian\_Wimmer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/sebastian_wimmer/32/769459_2.png) [@Sebastian\_Wimmer](https://discourse.mcneel.com/u/Sebastian_Wimmer)\
**Post date:** [November 22, 2024, 2:20pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/10 "2024-11-22T14:20:43Z")

</div>

@Measure thank you very much - this does exactly what I want - the perspective difference is so minor that its not a drama.

Still I wonder why this is not working natively?

Best regards and thank you very much for your script!  
sebowim

---

<div class="post-metadata">

**Author:** ![Measure](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/measure/32/651816_2.png) [@Measure](https://discourse.mcneel.com/u/Measure)\
**Post date:** [November 22, 2024, 2:22pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/11 "2024-11-22T14:22:53Z")

</div>

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.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/0/7/1/071f962ed066a6e3ccd46c1626e56cd8fe0339ba.jpeg)

---

<div class="post-metadata">

**Author:** ![Sebastian\_Wimmer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/sebastian_wimmer/32/769459_2.png) [@Sebastian\_Wimmer](https://discourse.mcneel.com/u/Sebastian_Wimmer)\
**Post date:** [November 22, 2024, 2:26pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/12 "2024-11-22T14:26:45Z")

</div>

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.

thank you!

---

<div class="post-metadata">

**Author:** ![lander](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/lander/32/511244_2.png) [@lander](https://discourse.mcneel.com/u/lander)\
**Post date:** [November 22, 2024, 5:10pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/13 "2024-11-22T17:10:36Z")

</div>

> [@Measure](#):
>
> 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.)
> 
> ```auto
> 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()
> 
> ```

> [@Sebastian\_Wimmer](#):
>
> @Measure thank you very much - this does exactly what I want - the perspective difference is so minor that its not a drama.
> 
> Still I wonder why this is not working natively?
> 
> Best regards and thank you very much for your script!

This is awesome! I had a feeling this was possible 🙂 Rhino the best CAD. 🥹

---

<div class="post-metadata">

**Author:** ![Benjamin\_Beofsich](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/benjamin_beofsich/32/637505_2.png) [@Benjamin\_Beofsich](https://discourse.mcneel.com/u/Benjamin_Beofsich)\
**Post date:** [January 16, 2025, 3:04pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/14 "2025-01-16T15:04:34Z")

</div>

Hey all!

Thanks so much for the information here.

When I try to load the script, it tells me following error (sorry, my OS is in German, maybe you Pro’s find the correct translation easier than me)

Maybe you can help on this?

* * *

## Rhino 8 RhinoScript

## Source: Kompilierungsfehler in Microsoft VBScript Error: Anweisungsende erwartet Line: 2 Char: 20 Code: from Rhino.Geometry import Vector3d

## OK

---

<div class="post-metadata">

**Author:** ![Sebastian\_Wimmer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/sebastian_wimmer/32/769459_2.png) [@Sebastian\_Wimmer](https://discourse.mcneel.com/u/Sebastian_Wimmer)\
**Post date:** [January 16, 2025, 3:13pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/15 "2025-01-16T15:13:27Z")

</div>

Hello @Benjamin_Beofsich, unfortunately I am not skilled enough to give you direct help - but in the meantime you can try to copy the script into chatgpt as well as the error and solve it there, just back-feed the errors until the script works - this procedure helped me a lot in the past, but keep in mind that you might not get the most elegant script…

---

<div class="post-metadata">

**Author:** ![Measure](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/measure/32/651816_2.png) [@Measure](https://discourse.mcneel.com/u/Measure)\
**Post date:** [January 16, 2025, 3:19pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/16 "2025-01-16T15:19:48Z")

</div>

The script is in python, and your error seems to indicate it’s expecting a VBScript. Use this macro to launch a python script:  
`_NoEcho !-_RunPythonScript "Script\full\path\here.py"`

---

<div class="post-metadata">

**Author:** ![Benjamin\_Beofsich](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/benjamin_beofsich/32/637505_2.png) [@Benjamin\_Beofsich](https://discourse.mcneel.com/u/Benjamin_Beofsich)\
**Post date:** [January 16, 2025, 7:06pm UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/17 "2025-01-16T19:06:05Z")

</div>

Legend, thank you. Solved for me

---

<div class="post-metadata">

**Author:** ![Eugen](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eugen/32/656992_2.png) [@Eugen](https://discourse.mcneel.com/u/Eugen)\
**Post date:** [May 16, 2025, 11:22am UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/18 "2025-05-16T11:22:11Z")

</div>

> [@Sebastian\_Wimmer](#):
>
> 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

That shouldn’t be so and doesn’t make sense, so: it’s a bug.  
Just came across this, too, again.

---

<div class="post-metadata">

**Author:** ![pawel](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pawel/32/732861_2.png) [@pawel](https://discourse.mcneel.com/u/pawel)\
**Post date:** [May 21, 2025, 8:42am UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/19 "2025-05-21T08:42:04Z")

</div>

Hi guys,

The script doesn’t work in Rhino 8 - it rotates the camera…

---

<div class="post-metadata">

**Author:** ![pawel](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pawel/32/732861_2.png) [@pawel](https://discourse.mcneel.com/u/pawel)\
**Post date:** [May 21, 2025, 8:45am UTC](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317/20 "2025-05-21T08:45:15Z")

</div>

Dear Rhino Team

We need this looked into. Please see below:  
The parallel views work fine:  
 ![20250521_103258_Rhino_wMweHJhl62](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/0/3/6/0369d621b038e4d9c8c598f495d723516785bd49.gif)

But the perspective doesn’t (even though it is locked):  
 ![20250521_103403_Rhino_ioe4GOC8Fl](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/8/f/2/8f26eda05cdbeba31268a5a7ae913f5da7de17b4.gif)

[Next page](https://discourse.mcneel.com/t/modify-perspective-detail-view-in-layout/195317.md?page=2)
