# Extract current viewing parameters from a 3D view?

Is there a way to find out the current viewing parameters of a 3D view? What often happens is that I create a view, for example:

Graphics3D[{Blue, Cuboid[], Yellow, Sphere[]}, Boxed -> False]


and then spend some time adjusting it using the mouse to pan, zoom, and rotate it:

Now I'd like to know what those settings (view point, etc.) are, so that they can be integrated as defaults into the next edit. It looks like an easy problem but I can't find out how to do it. At the moment there's a lot of trial and error involved.

-
See for example this answer by Yu-Sung Chang – Heike May 9 '12 at 11:28
Would you mind editing in code that can be copied (not just screenshots)? – Yves Klett May 9 '12 at 11:28
@YvesKlett sorry, didn't think the code was worth adding ... – cormullion May 9 '12 at 11:38
Nah, I´d say it is always worth prepping the question as far as possible to attract and encourage answers. – Yves Klett May 9 '12 at 11:42
BTW, the excellent upload palette works wonders here... – Yves Klett May 9 '12 at 11:44

You can dynamically extract ViewPoint and others like this (also useful for synchronization of different plots etc.):

vp = Options[Graphics3D, ViewPoint][[1, 2]];

Graphics3D[Cuboid[], ViewPoint -> Dynamic[vp]]


This value is now constantly updated:

Dynamic[vp]


{1.3, -2.4, 2.}

This seem also to work fine with other functions that use the ViewPoint option. Below, ViewPoint and ViewVertical are in sync for both objects:

{vp, vv} = Options[Graphics3D, {ViewPoint, ViewVertical}][[All, 2]];

Grid[{{Graphics3D[Cuboid[], ViewPoint -> Dynamic[vp],
ViewVertical -> Dynamic[vv]],
ParametricPlot3D[{Cos[u], Sin[u] + Cos[v], Sin[v]}, {u, 0,
2 Pi}, {v, -Pi, Pi}, ViewPoint -> Dynamic[vp],
ViewVertical -> Dynamic[vv]]}}]


-
Should this technique work with ParametricPlot3D, etc? – JohnD Nov 15 '12 at 1:51
@texasAUtiger yes it should... just about for any function using the ViewPoint option. – Yves Klett Nov 15 '12 at 7:37

Perhaps the most easiest way is to use Options

1. Graphics3D[Cuboid[]] to plot the figure;
2. Manipulate the figure at your will,such as zooming in, rotate and so on;
3. Copy the manipulated figure and add //Options after it, and press enter. You will get the options of the manipulated figure.

-
 I've put this to good use. I set variable view with a rotated-and-shrinked copy-pasted graphics gr with postfix extraction: view = gr // Options[#, {ViewPoint, ViewVertical}] & and then use Sequence @@ view in the cell that generated gr. – BoLe Apr 7 at 10:38

The following function may be helpful:

ExtrahiereViews[ll_]:=
Flatten[Union[Extract[ll,Position[ll,#]]&/@
{ViewPoint->_, ViewCenter->_, ViewVertical->_,
ViewAngle->_, ViewVector->_, ViewRange->_}]];


How to do:

1. Enter ExtrahiereViews[] in a cell below the graphic.
2. Move the graphic to your liking.
3. Set the cursor between the brackets of ExtrahiereViews.
4. Make a "Copy output from above" (CtrlShiftL) and evaluate. You'll get the values.
-
 Thanks - I can't get it working yet, but thanks nonetheless, still working on it. Do you mean copy the graphic into the place where the ll_ is? Then what happens to the ll? Also, should I remove the semicolon? And by Copy output from above do you mean "Insert>Output From Above" (command-shift-L on Mac)? – cormullion May 9 '12 at 12:15 Plus we learn the german translation for "extract" ;-) – Yves Klett May 9 '12 at 12:18 @cormullion 1.) If you don't move, rotate, ... the grahphics with the mouse, the output will be an empty list. 2.) Yes, you have to Ctrl+Shilt+L the graphcs between the [ ]. The ll used in the definition will then be replaces by the graphic (which is a mathematica object like any other). – Peter Breitfeld May 9 '12 at 12:22 This is how I do it now, thanks. Function defined shorter: ExtrahiereViews[ll_] := Options[ll, {ViewPoint, ViewVertical}] (will extract only two options I personally need). – BoLe Apr 7 at 10:46