Add Shape to GroupShapeEx

Hello,


I would add a Shape to a Groupshape, but this code not work for me:

PresentationEx thePresentation = new PresentationEx();

SlideEx theSlide = thePresentation.Slides[0];



GroupShapeEx theGrpShape = theSlide.Shapes[0] as GroupShapeEx;


theGrpShape.Slide.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, 0, 0, 200, 200);



thePresentation.Write("test.pptx");



Can you give me an Example ?

Thank you,
Marius W.

Hi Marius,

Well, at the moment, adding a new group shape is not supported by Aspose.Slides for .NET. However, you may add a new shape to an existing group shape. As a work around, you can use a template slide with group shape and then add your shape to that group shape. You may check and see if the below code helps in implementing your requirement.

// Instantiate PresentationEx class that represents PPTX
PresentationEx presentation = new PresentationEx("D:\\data\\input.pptx");

// Access first slide
SlideEx slide = presentation.Slides[0];

foreach (ShapeEx shape in slide.Shapes)
{
    if (shape.GetType() == typeof(GroupShapeEx))
    {
        //Getting group shapes
        GroupShapeEx gShape = (GroupShapeEx)shape;

        //Adding new Autoshape to existing group shape
        gShape.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, 300, 200, 100, 100);
    }
}

// Write the PPTX to Disk
presentation.Write("D:\\data\\GroupShape.pptx");

Thanks & Regards,
Owais Ahmad

Hi Marius W,

I like to share that the support for adding group shape from scratch is unavailable in Aspose.Slides at present. Owais, has shared the possible work around with you in terms of adding group shape with you. An issue with ID SLIDESNET-19279 has already been created in our issue tracking system to provide the requested support. This thread has been linked with the issue so that you may be automatically notifeid once the feature will be available.

We are sorry for your inconvenience,

The issues you have found earlier (filed as SLIDESNET-19279) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.