Free Support Forum - aspose.com

Animate a shape to exit

I want to use the pptx libraries to animate shapes to appear and then disappear.

I’ve located documentation on how make things appear and that’s working just fine, but I’m not seeing how to animate something to disappear. Specifically, I want the slide to start by fading in shape 1, then after a few seconds, make shape 1 fade out as shape 2 fades in.

Thanks in advance for your assistance.

Hi Ryder,


Thanks for your inquiring Aspose.Slides.

I have tried to understand the requirements shared by you. Please visit this documentation link for applying different animations on the shapes. Please observe EffectTypeEx enumeration in Aspose.Slides.chm file, it contains all the possible animation types supported by Aspose.Slides. Please share, if I may help you further in this regard.

Many Thanks,

Thank you for your reply. Your link does provide some good information about how to create a sequence of animations, however, it doesn’t completely answer my question. Please let me explain further.

I have the following line:
slide.Timeline.MainSequence.AddEffect(shape, EffectTypeEx.Appear, EffectSubtypeEx.None, EffectTriggerTypeEx.AfterPrevious);

I would like to do something like:
slide.Timeline.MainSequence.AddEffect(shape, EffectTypeEx.Disappear, EffectSubtypeEx.None, EffectTriggerTypeEx.AfterPrevious);

However, that doesn’t appear to be an option. In general I’m seeing how to animate something to appear but I’m missing what you do to make it disappear.

Hi Ryder,


I have worked over the requirements shared by you. I like to share that there is EffectEx class that is added for each effect associated with any slide. You can set the EffectPresetClassType property to exit and text will fade out. I also like to add that the appropriate property for EffectPresetClassType depends on used EffectTypeEx. I like to add further that supported effect types are available in EffectTypeEx animation and in following example I have disappeared the text from screen using animation.


public static void AddAnimcation()
{
//Instantiate PrseetationEx class that represents the PPTX
PresentationEx pres = new PresentationEx();
SlideEx sld = pres.Slides[0];

//Now create effect “PathFootball” for existing shape from scratch.
int idx = sld.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, 150, 150, 250, 25);
AutoShapeEx ashp = (AutoShapeEx)sld.Shapes[idx];
ashp.AddTextFrame(“Animated TextBox”);

//Add PathFootBall animation effect
ShapeEx shape = pres.Slides[0].Shapes[idx];
EffectEx eff = pres.Slides[0].Timeline.MainSequence.AddEffect(shape, EffectTypeEx.Blinds,
EffectSubtypeEx.None, EffectTriggerTypeEx.AfterPrevious);

eff.PresetClassType = EffectPresetClassTypeEx.Exit;

//Create some kind of “button”.
int index = pres.Slides[0].Shapes.AddAutoShape(ShapeTypeEx.Bevel, 10, 10, 20, 20);
ShapeEx shapeTrigger = pres.Slides[0].Shapes[index];

//Create sequence of effects for this button.
SequenceEx seqInter = pres.Slides[0].Timeline.InteractiveSequences.Add(shapeTrigger);

//Create custom user path. Our object will be moved only after “button” click.
EffectEx fxUserPath = seqInter.AddEffect(shape, EffectTypeEx.PathUser, EffectSubtypeEx.None, EffectTriggerTypeEx.OnClick);

//Created path is empty so we should add commands for moving.
MotionEffectEx motionBhv = ((MotionEffectEx)fxUserPath.Behaviors[0]);
PointF[] pts = new PointF[1];
pts[0] = new PointF(0.076f, 0.59f);
motionBhv.Path.Add(MotionCommandPathTypeEx.LineTo, pts, MotionPathPointsTypeEx.Auto, true);
pts[0] = new PointF(-0.076f, -0.59f);
motionBhv.Path.Add(MotionCommandPathTypeEx.LineTo, pts, MotionPathPointsTypeEx.Auto, false);
motionBhv.Path.Add(MotionCommandPathTypeEx.End, null, MotionPathPointsTypeEx.Auto, false);

//Write the presentation as PPTX to disk
pres.Write(“d:\AnimExample.pptx”);

}

Many Thanks,