Shape Geom data is always default shape values

Working on trying to convert visio diagram shapes to SVG paths. While looping through the shapes and the geometry data I noticed that the shapes always seemed to be coming in as the default values (same values as if you just dragged the Visio shape out). In the picture I marked that I changed all the values using the developer tools to 1 but while importing it still has the same value as the default. Is there something I am missing here? Is the data for how the geometry is transformed/manipulated somewhere else?

Code below is used to loop through the shape and make a list of SVG paths that can then be used to render the shape as an SVG. This is just the code for the cone shape.

public static void addSvgPathsForShape(Shape shape, List<String> path)
   {
      GeomCollection geomCollection = shape.getGeoms();
      for (Geom geom : (Iterable<Geom>) geomCollection)
      {
         PathagonBuilder pathagonBuilder = new PathagonBuilder();
         pathagonBuilder.moveTo(0.0, 0.0);
         for (Coordinate coordinate : (Iterable<Coordinate>) geom.getCoordinateCol())
         {
            if (coordinate instanceof LineTo)
            {
               LineTo lineTo = (LineTo) coordinate;
               double x = lineTo.getX().getValue();
               double y = -lineTo.getY().getValue();
               pathagonBuilder.lineTo(x, y);
            }
            else if (coordinate instanceof MoveTo)
            {
               MoveTo moveTo = (MoveTo) coordinate;
               double x = moveTo.getX().getValue();
               double y = -moveTo.getY().getValue();
               pathagonBuilder.moveTo(x, y);
            }
            else if (coordinate instanceof EllipticalArcTo) {
               EllipticalArcTo ellipticalArcTo = (EllipticalArcTo) coordinate;
               double arcX = ellipticalArcTo.getA().getValue();
               double arcY = -ellipticalArcTo.getB().getValue();
               double endX = ellipticalArcTo.getX().getValue();
               double endY = -ellipticalArcTo.getY().getValue();
               pathagonBuilder.ellipticalArcTo(arcX, Math.abs(arcY-endY), ellipticalArcTo.getC().getValue(), false, false, endX, endY);
            }
         }
         pathagonBuilder.closePath();
         path.add(pathagonBuilder.get().toSvgPath());
      }
   }

manually changed values.jpg (190.3 KB)
cone.7z (21.2 KB)

1 Like

@mcintken
Thanks for the template file and screenshots.

Please try this sample code to get the Geoms values for the shape inherit by the master shape.

GeomCollection geomCollection = shape.getInheritGeoms();

Thanks.

I tried changing geomCollection to the suggested code but unfortunately, it still gives me the “default values”. I’m still getting 0 for the x for the first MoveTo when in Visio it says it is 1. The same thing is happening to the EllipticalArcTo (not giving me 1 where expected).

@mcintken
I have tested your scenario/case using our latest version : Aspose.Diagram for Java v23.9 . It works fine and as expected.
It is strange as it works fine on my end using the latest version 23.9. Here is my sample code for your reference:

              else if (coordinate instanceof EllipticalArcTo) {
                EllipticalArcTo ellipticalArcTo = (EllipticalArcTo) coordinate;
                double arcX = ellipticalArcTo.getA().getValue();
                double arcY = -ellipticalArcTo.getB().getValue();
                double endX = ellipticalArcTo.getX().getValue();
                double endY = -ellipticalArcTo.getY().getValue();
              
	              System.out.println("arcX "+ arcX);
	              System.out.println("arcY " +arcY);
	              System.out.println("endX "+ endX);
	              System.out.println("endY " +endY);
             }

The output:
arcX 1.0
arcY -1.0
endX 1.0
endY -1.0

As you can see it works fine with latest version and we could not find any issue, so kindly use latest version. If you still find the issue with latest version, then please give more details to reproduce the issue. We will check your issue soon.
Thanks.

I can confirm that it works. It turned out that the shape being passed in was using the shape.getMasterShape() which was providing the default values.

@mcintken
Thanks for following the workaround and good know that your issue is sorted out.
Please feel free to contact us in case you have further comments or questions.
Thanks.