# Fit SliceView Zoom

**URL:** <https://discourse.slicer.org/t/fit-sliceview-zoom/19331>\
**Category:** Support\
**Created:** [August 24, 2021, 8:57am UTC](https://discourse.slicer.org/t/fit-sliceview-zoom/19331 "2021-08-24T08:57:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [August 24, 2021, 8:57am UTC](https://discourse.slicer.org/t/fit-sliceview-zoom/19331/1 "2021-08-24T08:57:20Z")

</div>

Hi everyone!  
I´m trying to fit a reformat slice view to volume size.  
I´ve finded slicer.util.setSliceViewerLayers(volumeNode, fit=True) but it reset also position and orientation. I´ve tried also sliceLogic.FitSliceToAll() but with same results.  
Is there any way to just fit zoom of slice view?  
Thanks on advance

---

<div class="post-metadata">

**Author:** ![riep](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/riep/32/9933_2.png) [@riep](https://discourse.slicer.org/u/riep)\
**Post date:** [August 25, 2021, 7:45am UTC](https://discourse.slicer.org/t/fit-sliceview-zoom/19331/2 "2021-08-25T07:45:30Z")

</div>

Hi Angel,  
If you want to avoid rotation, you could use.

> appLogic = slicer.app.applicationLogic()  
> appLogic.FitSliceToAll(True, False)

However, I would say that position change is the normal behavior.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 5, 2021, 2:06am UTC](https://discourse.slicer.org/t/fit-sliceview-zoom/19331/3 "2021-09-05T02:06:59Z")

</div>

If you want to center the volume except you want to keep the current slice offset (just zoom in/out and pan to center the volume but keep the current slice) then you can save the slice offset before centering and then restore it:

```python
sliceLogic = slicer.app.applicationLogic().GetSliceLogicByLayoutName("Red")
offset = sliceLogic.GetSliceOffset()
sliceLogic.FitSliceToAll()
sliceLogic.SetSliceOffset(offset)

```
