# How to pull Position and Focal Point data from default scene camera for camera angle extension

**URL:** <https://discourse.slicer.org/t/how-to-pull-position-and-focal-point-data-from-default-scene-camera-for-camera-angle-extension/3195>\
**Category:** Development\
**Tags:** extensions-manager\
**Created:** [June 15, 2018, 3:24pm UTC](https://discourse.slicer.org/t/how-to-pull-position-and-focal-point-data-from-default-scene-camera-for-camera-angle-extension/3195 "2018-06-15T15:24:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cbloodworth3](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@cbloodworth3](https://discourse.slicer.org/u/cbloodworth3)\
**Post date:** [June 15, 2018, 3:24pm UTC](https://discourse.slicer.org/t/how-to-pull-position-and-focal-point-data-from-default-scene-camera-for-camera-angle-extension/3195/1 "2018-06-15T15:24:45Z")

</div>

Hi folks,

I’m trying to create an extension which will calculate the angle of the default scene camera w.r.t. the subject in the slicer 3D scene. This would be analogous determining the C-Arm LAO/RAO and CRA/CAU angles for proper image orientation.

The calculation is pretty straightforward and can be done with nothing but the camera position and focal point, but I can’t seem to obtain these values using GetPosition and GetFocalPoint. Here are some code snips:

```
>>> defaultCam = slicer.mrmlScene.GetNodeByID('vtkMRMLCameraNode1')
>>> defaultCamPosition = defaultCam.GetPosition()
>>> print(defaultCamPosition)
_000001eb844fabd8_p_void

```

On the other hand, GetCameraAngle does function as expected:

```
>>> viewAngle1 = defaultCam.GetViewAngle()
>>> print(viewAngle1)
30.0

```

Additionally, both SetPosition and SetFocalPoint function as expected. In fact, all of these are listed as valid member functions for the [vtkMRMLCameraNode Class](http://apidocs.slicer.org/master/classvtkMRMLCameraNode.html#a4553e1ad9a18365981b49790ef25d75a):

Finally, if I browse to this node in the slicer data module, all of these values are listed in the node information.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/b/7bf44f093c8cc33e19839d7d7425f016d1ed95f0.png)

Any ideas on how to programmatically obtain the default scene camera position and focal point values?

Thanks for the help.

---

<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:** [June 15, 2018, 4:39pm UTC](https://discourse.slicer.org/t/how-to-pull-position-and-focal-point-data-from-default-scene-camera-for-camera-angle-extension/3195/2 "2018-06-15T16:39:03Z")

</div>

You can use `GetPosition(double*)` variant:

```
>>> defaultCam = slicer.mrmlScene.GetNodeByID('vtkMRMLCameraNode1')
>>> pos=[0,0,0]
>>> defaultCam.GetPosition(pos)
>>> pos
[54.62253179056516, 118.36363864842811, 61.73342989137638]
```

---

<div class="post-metadata">

**Author:** ![cbloodworth3](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@cbloodworth3](https://discourse.slicer.org/u/cbloodworth3)\
**Post date:** [June 15, 2018, 4:55pm UTC](https://discourse.slicer.org/t/how-to-pull-position-and-focal-point-data-from-default-scene-camera-for-camera-angle-extension/3195/3 "2018-06-15T16:55:19Z")

</div>

> [@lassoan](#):
>
> \>\>\> defaultCam = slicer.mrmlScene.GetNodeByID(‘vtkMRMLCameraNode1’) \>\>\> pos=[0,0,0] \>\>\> defaultCam.GetPosition(pos) \>\>\> pos [54.62253179056516, 118.36363864842811, 61.73342989137638]

Thanks Andras, I suppose I misunderstood the \*double variant of this function. It’s a void function which assigns ‘None’ to the output, but changes the input argument to the position. For example:

```
>>> pos = [0,0,0]
>>> cameraPosition = defaultCam.GetPosition(pos)
>>> print(cameraPosition)
None
>>> pos
[3.0, 3.0, 3.0]

```
