While add shape and remove old shape - shape order missing

Hi,
We have visio diagram that diagram have excel (Embedded object). So collect the Excel objects and convert that excels to image, Then add the image to excel position and remove the excels.
After adding image, Some Image going background.
Please help how to show the shape above the image.
Input: InputFiles.zip (128.2 KB)

Output: OutputFiles.zip (89.5 KB)

Issue File Name(Excel Missing) : Excel Missing_out.vsdx - We have attached three files. please find the issue file in the attachment.

Code: VisioToExcel (2).zip (2.2 KB)

Please have look.

We are waiting for your reply and support.

Thanks.

@msindia

Thanks for contacting support.

We have logged an investigation ticket as DIAGRAMNET-51847 in our issue tracking system to investigate your requirements. We will surely look into its further details and keep you posted with the status of ticket resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

@asad.ali,
We hope your doing well. Regarding the ticket ‘DIAGRAMNET-51847’ any update let us know.

Thanks

@msindia

Regretfully, the ticket is not yet resolved. However, we have recorded your concerns and will surely update you as soon as we have some definite updates in this regard. Please give us some time.

@asad.ali,

This ticket is ‘Resolved’ state. Please give the changes of code.

If you did the new changes with the above attached files. Is everything solved?
If solved please share the code changes with us.
let us know.

Thanks.

@msindia

For the sample file named “Excel Missing.vsdx”, when deleting the excel and add the image to the visio manually Using MS Visio - you will find the newly added shape is a new shape but not the child of the parent shape. So please just remove the child and do not add this newly shape to the parent shape.

if (sParentShape == null)
{                    
 vsdDiagram.Pages[0].Shapes.Remove(shape);                    
 sh.SendBackward();
}                
else
{                    
 //sh.ParentShape = sParentShape;                    
 //shape.ParentShape.Shapes.Add(sh);                    
 //vsdDiagram.Pages[0].Shapes.Remove(sh);                    
 sParentShape.Shapes.Remove(shape);                    
 //sh.SendBackward();                
}

@msindia

For the sample file named “Excel Missing.vsdx”, when deleting the excel and add the image to the visio manually Using MS Visio - you will find the newly added shape is a new shape but not the child of the parent shape. So please just remove the child and do not add this newly shape to the parent shape.

if (sParentShape == null)
{                    
 vsdDiagram.Pages[0].Shapes.Remove(shape);                    
 sh.SendBackward();
}                
else
{                    
 //sh.ParentShape = sParentShape;                    
 //shape.ParentShape.Shapes.Add(sh);                    
 //vsdDiagram.Pages[0].Shapes.Remove(sh);                    
 sParentShape.Shapes.Remove(shape);                    
 //sh.SendBackward();                
}

@asad.ali,
Thanks for your reply,
For your solution is only solve ‘Excel Missing.vsdx’ file. Other files are problem, check with your change the remaining files image is missing see my attachment.
Output: image.png (105.3 KB) - Dialog3.vsdx

Please give general solution or any other approach.
Waiting for your support and reply.
Thanks

@msindia

We have recorded your concerns and will update you in case of any further update regarding investigation of this scenario.

@asad.ali,

We hope you are doing well. May I know the task status.

Thanks.

@msindia

The ticket is still under the investigation phase sadly and we will surely inform you as soon as investigation is done. Please give us some time.

We are sorry for the inconvenience.

@msindia

Please try to send the child shape backward when it is a group shape like this sample code:

           if (sParentShape == null)
                {
                    vsdDiagram.Pages[0].Shapes.Remove(shape);
                    sh.SendBackward();

                }
                else
                {
                    sh.ParentShape = sParentShape;
                    shape.ParentShape.Shapes.Add(sh);
                    vsdDiagram.Pages[0].Shapes.Remove(sh);
                    
                    sParentShape.Shapes.Remove(shape);
                    sh.SendBackward();

                    //send shape to backward when it is a group shape
                    for (int i = 0; i < sParentShape.Shapes.Count;i++ )
                    {
                        Shape child = sParentShape.Shapes[i];
                        if (child.Type == TypeValue.Group)
                        {
                            child.SendBackward();
                        }
                    }
                }

@asad.ali,
Thanks for your reply. I will check and update.

Thanks