Free Support Forum - aspose.com

Shapes linked to a Container

Hello,


First of all, thanks for the big help that you provide every-time that we are stuck.

I need to know if there is a way to know the shapes linked to a “Container”.
In the file attached you will find two element represented “Sample1” & “Sample2”.
Everyone of them has a set of shapes and groups that defines it.
What I’m trying to do is just to figure out how to get the containers and also the shapes linked to them.
I did try to search in aspose diagram library but I didn’t find much things on containers.

Hi Achraf,


Thank you for contacting support. Please note, the shapes inside the container are not in a group. You have direct access to retrieve a shape by ID and filter out its incoming and outgoing nodes. For example, in your Visio diagram, there are two containers. A group shape (ID: 34) inside the first container is connected to the group shape (ID: 49) of the second container. The shape ID 49 has a single incoming node. It can be retrieved using the connectedShapes method of shape class.

Sample code:
[Java]
<span style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>// set directory path
String dataDir = “C:\AD\test684\”;
// load a Visio diagram
Diagram diagram = new Diagram(dataDir + “testOnePool.vsd”);
// get page by name
Page page = diagram.getPages().getPage(“Identify a stakeholder”);
// get shape by id
Shape con1grpshape = page.getShapes().getShape(49);
// get incoming nodes
long[] connectedShapeIds = con1grpshape.connectedShapes(ConnectedShapesFlags.CONNECTED_SHAPES_INCOMING_NODES, null);
// display incoming node IDs
for(long shapeid : connectedShapeIds)
System.out.println("Shape ID: " + shapeid);

Result:
Shape ID: 34

Please also refer to this help topic: Get the Shapes Connected to a Particular Shape

Thank you for the explanation but what we are looking for is more than just getting the ID of the objects.we are looking exactly for what it links them together.


what we are looking for it’s already implemented in Visio VBA. there is a way to get a shape as a container and get all the elements in it.

here is a link to the object container where there is a set of methods to get all the member of a container.

https://msdn.microsoft.com/en-us/library/office/ff768029.aspx

Thanks.

Hi Achraf,


Thank you for the inquiry. It appears as you are looking to retrieve all member shapes of a container shape. This feature is already available by using Aspose.Diagram API. The Relationships cell of the shape Layout Section stores the relationships between containers, lists, callouts, and member shapes. It uses a DEPENDSON function with one additional parameter for each member shape of the container. Using Aspose.Diagram API, you can retrieve a formula string, and then retrieve member shape ID’s by applying a regular expression.

However, we have tested your sample Visio diagram against the latest version 6.8.0. It does not retrieve user cells and relationships cell of the container shape. We have logged these issues in our bug tracking system as below:

DIAGRAMJAVA-50376: Can’t retrieve all user cells of a container shape from a VSD diagram
DIAGRAMJAVA-50377: Can’t retrieve relationships cell of the container shape from a VSD

Your post has also been linked to these tickets. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.

[Java]
<span style=“color: rgb(0, 128, 0); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>// load an existing Visio diagram
Diagram diagram = new Diagram(“C:\AD\test684\testOnePool.vsd”);

// get a container shape by ID
Shape cntShape = diagram.getPages().getPage(“Identify a stakeholder”).getShapes().getShape(4);
// verify whether it is a container shape
// the value of user cell “msvStructureType” should be “Container”
// extract user defined cells of the shape
for (User user : (Iterable) cntShape.getUsers())
if(user.getName() == “msvStructureType” && user.getValue().getVal().toLowerCase() == “container”)
System.out.println(“It is a container shape.”);

// get member shape IDs of the container
// Note: please apply a regular expression to get all member shape IDs from the formula string
String formula = cntShape.getLayout().getRelationships().getUfe().getF();
System.out.println(formula);

Hi Achraf,


Thank you for being patient. We have a good news for you that the issue ID DIAGRAMJAVA-50377 has now been resolved. If there is no issue in the QA phase, then this fix will be included in the next version of Aspose.Diagram for Java 6.9.0. We’ll inform you via this forum thread as soon as the new release is published.

Hi Achraf,


Thank you for being patient. In reference to the ticket ID DIAGRAMJAVA-50377, please download and use the latest Hotfix version: Aspose.Diagram for Java 6.8.1. Please also let us know how that goes on your side.

Hi Achraf,


Thank you for being patient. In reference to the ticket ID DIAGRAMJAVA-50376, please retrieve user cells from the master shape as below:

[Java]
// get the user cell values
for (User user : (Iterable) cntShape.getMasterShape().getUsers())
if(user.getName().equals(“msvStructureType”) && user.getValue().getVal().toLowerCase().equals(“container”))
System.out.println(“It is a container shape.”);

Note: the ticket ID DIAGRAMJAVA-50376 has now been closed.

Hello Imrane,

I hope that you are doing fine :slight_smile:


I did some tests on the new fix that you gave us and I found that we have some changes on the previous versions.
Now we can get the relationships but I still can’t get the members of a container.
In the Visio file attached I have two elements (shape 1 & shape 2) linked to the main container (Sample 1).
through the Function we can get the name of the container/pool lane (Sample 1) but when I’m using the code below that you gave me I get nothing referencing that the element “Sample 1” has two elements “Shape 1” & “Shape 2”.

for (Shape shape : (Iterable) vdxDiagram.getPages().get(0).getShapes()) {
for (User user : (Iterable) shape.getMasterShape().getUsers()) {
if (user.getName().equals(“msvStructureType”) && (user.getValue().getVal().toLowerCase().equals(“container”))) {
System.out.println("Shape ID : " + shape.getID() + "Name : " + shape.getName());
System.out.println(“It is a container shape.”);
System.out.println("Formula : " + shape.getLayout().getRelationships().getUfe().getF());
System.out.println("");
}
}
}

The results are:
Shape ID : 299Name : Sheet.299
It is a container shape.
Formula : SUM(DEPENDSON(1,))
Shape ID : 295Name : Sheet.295
It is a container shape.
Formula :
Shape ID : 304Name : Sheet.304
It is a container shape.
Formula :
Process Completed Successfully


If I try to get the information directly from the shapes I get also some wrong results :

for (Shape shape : (Iterable) vdxDiagram.getPages().get(0).getShapes()) {
System.out.println("Shape ID : " + shape.getID() + "Name : " + shape.getNameU() + " label " + PalyWithSHape.getName(shape));
System.out.println("Formula : " + shape.getLayout().getRelationships().getUfe().getF());
System.out.println("");
}

Shape ID : 328Name : Process.327 label Shape 2 ID : 328
Formula : SUM(DEPENDSON(4,))
Shape ID : 329Name : Process.329 label Shape 1 ID : 329
Formula : SUM(DEPENDSON(4,))
*******************
Process Completed Successfully


Hi Achraf,

Thank you for the details. We managed to replicate the problem of not being able to retrieve the complete formula string of relationships cell as visible in the shape sheet. It has been logged under ticket ID DIAGRAMJAVA-50418 in our bug tracking system. Your post has also been linked to this ticket. We'll keep you informed regarding any available updates. We're sorry for the inconvenience caused.

Hi Achraf,


Thank you for being patient. We have a good news for you that the ticket ID DIAGRAMJAVA-50418 has now been resolved. If there is no issue in the QA phase, then this fix will be included in the next version 6.9.0 of Aspose.Diagram for Java API. We’ll inform you via this forum thread as soon as the new release is published.

The issues you have found earlier (filed as DIAGRAMJAVA-50377;DIAGRAMJAVA-50418) have been fixed in Aspose.Diagram for Java 16.10.0.


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

Hello,

First of all, thank you for the good support for all the aspose products that we use.

I didn’t want to create a new topic because this one has all the history and the information needed to understand the context of my problem.

As you see above in the previous conversations I’m using the informations stored in the formulat of a shape using the method below :
shape.getLayout().getRelationships().getUfe().getF()

My purpose is to find a way to get the information that the shapes and the container are linked in a way.
if you open a shape properties you will find in the Formula section the name of the container.

in the vsd file (attached) everything is working fine and I can get the information that I want.
But for the same diagram in vsdx unfortunately I can’t.

in the attched file you will have two files. One in VSD and the other one in VSDX format And you can replicate the problem.

arkParticipant.zip (63.3 KB)arkParticipantVSDVersion.zip (92.7 KB)

@eljuventino

Thanks for getting back to us.

We have logged an issue as DIAGRAMJAVA-50689 in our issue tracking system for the sake of further investigation. We will surely keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

@eljuventino

Using the sample code with version 20.3.1, the formula of the shape is fine.

for (com.aspose.diagram.Shape shape : (Iterable<com.aspose.diagram.Shape>) diagram.getPages().getPage(0).getShapes()) {
System.out.println("\nShape ID : " + shape.getID());
System.out.println(shape.getLayout().getRelationships().getUfe().getF());
}

Please kindly provide information that which shape is wrong if latest version does not help.

I tried with the latest version and the problem still the same.
The information returned for the formula is not the same when you run a VSDX file and a VSD file even if they are the same diagram.

when I’m using the vsd file I get the following output :

Shape ID : 1
SUM(DEPENDSON(1,Separator.41!SheetRef(),Swimlane List.39!SheetRef()))

Shape ID : 4
SUM(DEPENDSON(1,Process.112!SheetRef(),Rectangle!SheetRef()),DEPENDSON(11,Separator.41!SheetRef()),DEPENDSON(2,Swimlane!SheetRef()),DEPENDSON(4,CFF Container.38!SheetRef()))

Shape ID : 5
SUM(DEPENDSON(5,Swimlane List.39!SheetRef()),DEPENDSON(1,Process.112!SheetRef(),Rectangle!SheetRef()))

Shape ID : 8
SUM(DEPENDSON(11,Swimlane List.39!SheetRef()),DEPENDSON(2,Process!SheetRef()),DEPENDSON(4,CFF Container.38!SheetRef()))

When I’m using a vsdx file for the same diagram I get the following results :

Shape ID : 1
SUM(DEPENDSON(1,Sheet.8!SheetRef(),Sheet.4!SheetRef()))

Shape ID : 4
SUM(DEPENDSON(1,Sheet.74!SheetRef(),Sheet.18!SheetRef()),DEPENDSON(11,Sheet.8!SheetRef()),DEPENDSON(2,Sheet.5!SheetRef()),DEPENDSON(4,Sheet.1!SheetRef()))

Shape ID : 5
SUM(DEPENDSON(5,Sheet.4!SheetRef()),DEPENDSON(1,Sheet.74!SheetRef(),Sheet.18!SheetRef()))

Shape ID : 8
SUM(DEPENDSON(11,Sheet.4!SheetRef()),DEPENDSON(2,Sheet.9!SheetRef()),DEPENDSON(4,Sheet.1!SheetRef()))

@eljuventino

Thanks for your feedback.

We will further investigate the earlier logged ticket according to your provided information and share our feedback with you soon.

The issues you have found earlier (filed as DIAGRAMJAVA-50689) have been fixed in Aspose.Diagram for Java 20.4.

Hello !

I just tried the new version 20.4 and I can see that we still have the same problem. The value of the Formula is not correct !!!
in the attached file you can run both files (vsd & vsdx) with the code below and you will have different results even if they have the same diagram.

results for the vsd file
Shape ID : 1
SUM(DEPENDSON(1,Phase List.40!SheetRef(),Swimlane List.39!SheetRef()))

Shape ID : 4
SUM(DEPENDSON(1,Process.112!SheetRef(),Process.4!SheetRef()),DEPENDSON(11,Phase List.40!SheetRef()),DEPENDSON(2,Swimlane.47!SheetRef()),DEPENDSON(4,CFF Container.38!SheetRef()))

Shape ID : 5
SUM(DEPENDSON(5,Swimlane List.39!SheetRef()),DEPENDSON(1,Process.112!SheetRef(),Process.4!SheetRef()))

results for the vsdx file

Shape ID : 1
SUM(DEPENDSON(1,Sheet.8!SheetRef(),Sheet.4!SheetRef()))

Shape ID : 4
SUM(DEPENDSON(1,Sheet.74!SheetRef(),Sheet.18!SheetRef()),DEPENDSON(11,Sheet.8!SheetRef()),DEPENDSON(2,Sheet.5!SheetRef()),DEPENDSON(4,Sheet.1!SheetRef()))

Shape ID : 5
SUM(DEPENDSON(5,Sheet.4!SheetRef()),DEPENDSON(1,Sheet.74!SheetRef(),Sheet.18!SheetRef())) 

arkParticipantTests.zip (153.1 KB)

@eljuventino

When you use Microsoft Visio to save this sample file to .vsdx ,The formula of relationship is “SUM,Swimlane List.39!SheetRef()))” and “Phase List.40” is shape name with ID 8, also “Swimlane List.39” is shape name with ID 4.

We have fixed the issue for the wrong formula when loading .vsd such as Shape ID : 1
SUM,Swimlane List.39!SheetRef())) and this fix was included in 20.4. However, we have logged your feedback along with the ticket and will share updates with you as soon as we investigate them.

PS: As you already have raised this issue in priority support, you may please also follow up there so that issue can be dealt accordingly.

Dear team I am using the latest version of Aspose with C#. I am getting the same issue.

Let me know if there is a way to know which container shapes contains which shapes using aspose.
A sample code would be really helpful.

Thanks,
Prasenjeet