# How to adjust the object size in 3D only display area?

**URL:** <https://discourse.slicer.org/t/how-to-adjust-the-object-size-in-3d-only-display-area/22152>\
**Category:** Support\
**Tags:** vtk, python\
**Created:** [February 24, 2022, 7:55am UTC](https://discourse.slicer.org/t/how-to-adjust-the-object-size-in-3d-only-display-area/22152 "2022-02-24T07:55:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![user4](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/user4/32/13172_2.png) [@user4](https://discourse.slicer.org/u/user4)\
**Post date:** [February 24, 2022, 7:55am UTC](https://discourse.slicer.org/t/how-to-adjust-the-object-size-in-3d-only-display-area/22152/1 "2022-02-24T07:55:24Z")

</div>

Hi,all.I am struggling with this task,I will be very grateful if anyone can give me some possible advice.  
This question is more about **vtk**.  
I have a cube(volume) and the information is as follows:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/9/c9741cf72dd83f8b2a0ef1fc4837580aad36e547.png)  
 ![1645688079(1)](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/b/ebffeff1d56856a4068d6e620faea4ac0e61c62a.png)

_image dimensions \* image spacing = 30,30,40_(mm)  
So I want to adjust the camera to make sure the size of volume is 30(mm)x30(mm)x40(mm) and also I use the P-A orientation and show the ruler as follows:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/1/119020613697755f201b19d5f3af1b2834c34e33.png)

So my goal is to make sure the rectangle is 30mm by 40 mm in this case.  
I can get the camera

```auto
view = slicer.app.layoutManager().threeDWidget(0).threeDView()
renderWindow = view.renderWindow()
renderers = renderWindow.GetRenderers()
renderer = renderers.GetItemAsObject(0)
camera = renderer.GetActiveCamera() 

```

Also,I have many parameters

```auto
angle = math.radians(camera.GetViewAngle())
point = camera.GetFocalPoint()
direction = camera.GetDirectionOfProjection()
scale = camera.GetParallelScale()
distance = scale / math.sin(.5 * angle)

```

I wonder if there is a way to calculate the width and height of the cube with above parameters and adjust the camera to make the size of the cube become the one I need.

Thank you in advance for your help!  
Regards!
