We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Creating a GeometryShape using GeometryPath Does Not Work

I want to create a geometryShape on my slide and set its path. Here is my code, it doesn’t work.
slide. java 21.02

		IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 200, 200);

		GeometryShape geometryShape = (GeometryShape) autoShape;
		
		for (int i = 0; i < pathArr.length; i++) {
		
			IGeometryPath geometryPath = new GeometryPath();
			
			byte pathType = getPathType();
            if (pathType == PathCommandType.MoveTo) {
                geometryPath.moveTo(value[0], value[1]);
            } else if (pathType == PathCommandType.LineTo) {
                geometryPath.lineTo(value[0], value[1]);
            } else if (pathType == PathCommandType.ArcTo) {
                geometryPath.arcTo(value[0], value[1], value[2], value[3]);
            } else if (pathType == PathCommandType.QuadBezierTo) {
                geometryPath.quadraticBezierTo(value[0], value[1], value[2], value[3]);
            } else if (pathType == PathCommandType.CubicBezierTo) {
                geometryPath.cubicBezierTo(value[0], value[1], value[2], value[3], value[4], value[5]);
            } else if (pathType == PathCommandType.Close) {
                geometryPath.closeFigure();
            }
			
			geometryPathList.add(geometryPath);
			
		}
			
		IGeometryPath[] geometryPaths = geometryPathList.toArray(new IGeometryPath[0]);

		geometryShape.setGeometryPaths(geometryPaths);

@iyyb930,
Thank you for contacting support. We will reply to you as soon as possible.

@iyyb930,
Unfortunately, I cannot use your code snippet that contains some unknown variables. I checked the following simple code example. It works fine on my side with Aspose.Slides 21.2 and the latest version.

var presentation = new Presentation();
var slide = presentation.getSlides().get_Item(0);
IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 100, 100, 200, 200);

GeometryShape geometryShape = (GeometryShape) autoShape;

IGeometryPath geometryPath = new GeometryPath();
geometryPath.moveTo(0, 0);
geometryPath.lineTo(100, 0);
geometryPath.lineTo(100, 100);
geometryPath.closeFigure();

IGeometryPath[] geometryPaths = new IGeometryPath[1];
geometryPaths[0] = geometryPath;

geometryShape.setGeometryPaths(geometryPaths);

presentation.save("output.pptx", SaveFormat.Pptx);
presentation.dispose();

Please try to isolate the problem.

Documents: Custom Shape
API Reference: GeometryShape Class | GeometryPath Class