# How to access center view in the 3dwidget using code without pressing the center view option?

**URL:** <https://discourse.slicer.org/t/how-to-access-center-view-in-the-3dwidget-using-code-without-pressing-the-center-view-option/34643>\
**Category:** Support\
**Created:** [March 1, 2024, 11:53am UTC](https://discourse.slicer.org/t/how-to-access-center-view-in-the-3dwidget-using-code-without-pressing-the-center-view-option/34643 "2024-03-01T11:53:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebin1234](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebin1234/32/70096_2.png) [@ebin1234](https://discourse.slicer.org/u/ebin1234)\
**Post date:** [March 1, 2024, 11:53am UTC](https://discourse.slicer.org/t/how-to-access-center-view-in-the-3dwidget-using-code-without-pressing-the-center-view-option/34643/1 "2024-03-01T11:53:19Z")

</div>

How to access center view in the 3dwidget using code without pressing the center view option?.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 1, 2024, 12:07pm UTC](https://discourse.slicer.org/t/how-to-access-center-view-in-the-3dwidget-using-code-without-pressing-the-center-view-option/34643/2 "2024-03-01T12:07:47Z")

</div>

This is the simplest way I think

```auto
slicer.app.layoutManager().threeDWidget(0).threeDController().resetFocalPoint()

```

I checked and this can also be found in the script repository  
[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#center-the-3d-view-on-the-scene](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#center-the-3d-view-on-the-scene)  
I encourage everyone to check there first for pieces of code.

---

<div class="post-metadata">

**Author:** ![ebin1234](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebin1234/32/70096_2.png) [@ebin1234](https://discourse.slicer.org/u/ebin1234)\
**Post date:** [March 1, 2024, 12:15pm UTC](https://discourse.slicer.org/t/how-to-access-center-view-in-the-3dwidget-using-code-without-pressing-the-center-view-option/34643/3 "2024-03-01T12:15:37Z")

</div>

Thank You . It is working. I have a doubt in positioning the 3D view. If I want to place 3D view in anterior or posterior position . What I have to do using code?.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [March 1, 2024, 12:29pm UTC](https://discourse.slicer.org/t/how-to-access-center-view-in-the-3dwidget-using-code-without-pressing-the-center-view-option/34643/4 "2024-03-01T12:29:35Z")

</div>

You can review the API documentation associated with the 3D view the find all the various methods involved with that functionality. I’d suggest using that along with the script repository examples to help you learn how you would find how to do X functionality with the 3D view through Python.

[https://apidocs.slicer.org/main/classqMRMLThreeDView.html#a771517a8f8d6be954eab97e453b987e6](https://apidocs.slicer.org/main/classqMRMLThreeDView.html#a771517a8f8d6be954eab97e453b987e6)

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 1, 2024, 12:59pm UTC](https://discourse.slicer.org/t/how-to-access-center-view-in-the-3dwidget-using-code-without-pressing-the-center-view-option/34643/5 "2024-03-01T12:59:45Z")

</div>

A relevant example:  
`threeDWidget.threeDController().lookFromAxis(ctk.ctkAxesWidget.Superior)`

But I also suggest looking at the available functions instead of asking about them individually.
