RE: Automatic Closing of Animation Graphics Cells
- To: mathgroup at smc.vnet.net
- Subject: [mg37997] RE: [mg37978] Automatic Closing of Animation Graphics Cells
- From: "David Park" <djmp at earthlink.net>
- Date: Mon, 25 Nov 2002 01:56:26 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Robert, The following usually works. Animate[ Plot[ Sin[x t], {x, -Pi, Pi}, PlotRange -> {-1.1, 1.1} ], {t, 0, 1}, Frames -> 10 ]; SelectionMove[EvaluationNotebook[], All, GeneratedCell] FrontEndTokenExecute["OpenCloseGroup"]; FrontEndTokenExecute["SelectionAnimate"]; The last three statements can be pasted in using the DrawGraphics palette that comes with the DrawGraphics package at my web site. But sometimes the FrontEnd starts the animation before closing the group. So I have lately been using the following instead. Animate[ Plot[ Sin[x t], {x, -Pi, Pi}, PlotRange -> {-1.1, 1.1} ], {t, 0, 1}, Frames -> 10 ]; SelectionMove[EvaluationNotebook[], All, GeneratedCell] FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.01]; FrontEndExecute[{FrontEnd`SelectionAnimate[200, AnimationDisplayTime -> 0.1, AnimationDirection -> ForwardBackward]}] The Pause ensures that the cell group is closed before the animation starts. The last statement gives more control over the animation. The first parameter in FrontEnd`SelectionAnimate is the time in seconds to run the animation. The AnimationDisplayTime is the time in seconds to display each frame. The AnimationDirection can be Forward, Backward or ForwardBackward. The only problem I have with this is that Pause is supposed to work down to $TimeUnit, which on my Mathematica is 1/1000 (second). But I can never obtain a pause of less than a second. This is acceptable for the purpose, but it does seem to be a bug in Pause. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Dr. Robert Kragler [mailto:kragler at fh-weingarten.de] To: mathgroup at smc.vnet.net Hello, I am stuck with subsequent problem of FrontEnd programming. Perhaps, someone knows the solution. I would appreciate an answer : when a sequence of graphics cells for an animation is generated it would be favorable if all subsequent graphics cells would be grouped with respect to the top graphic cell (and not with respect to the preceding input cell evaluated). Then the graphics cells to be grouped should be closed so that only the top level graphics cell is visible and animation is started with double- clicking the top level graphics cell only. I found a partial solution which does the correct marking of the graphics cells being generated by a command such as Animate[ Plot[ Sin[x t], {x,-Pi,Pi} ], Frames -> 3 ]; CloseAniSequenceTest where the following code for manipulating the notebook is used : CloseAniSequenceTest := Module[ { }, SelectionMove[ EvaluationNotebook[ ], After, EvaluationCell ]; SelectionMove[ EvaluationNotebook[ ], Next, Cell ]; SelectionMove[ EvaluationNotebook[ ], Next, GeneratedCell ]; ????? FrontEndTokenExecute["OpenCloseGroup"] ] But before using the final command FrontEndTokenExecute["OpenCloseGroup"] there should be another command preceding that actually does the cell grouping wanted. The option SetOption[ NotebookSelection[ ], CellGrouping -> Automatic ] does not perform the action I expected, and I could not find any hint in chapt. 2.10 of the Mathematica book for the solution. With the code above the graphics cells are marked correctly using the command CloseAniSequenceTest but no cell grouping as intended is done. Which additional Notebook command has to be inserted instead of "????". I think only one additional line of code is required to do this but I cannot not find the right answer. Thanks in advance. Robert Kragler --------------------------------------------------------------------- Prof. Dr. Robert Kragler Fachhochschule Ravensburg-Weingarten University of Applied Sciences FB Physikalische Technik / Rechenzentrum P.O.B 1241 , D-88241 Weingarten Germany Tel: +49 (751) 501-9603 Fax: +49 (751) 501-5-9603 E-Mail: kragler at rz.fh-weingarten.de HomePage: http://www.fh-weingarten.de/ ---------------------------------------------------------------------