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

Free Support Forum - aspose.com

How to make a straight connector when building a new diagram

Greetings All, I am a newbie trying to evaluate the project (doing proof of concept).
I am building a new diagram from scratch in code and I want the connectors that I create to be straight.
This will create a connector and I can connect it fine but I want the connector to be a straight line. What do I have to do?

        Shape connectorShape1 = new Shape();

When I tried to use (taken from the example in SetConnectorAppearance.java)
I get the following exception:
Cannot invoke “com.aspose.diagram.Shape.getGeoms()” because the return value of “com.aspose.diagram.Shape.getMasterShape()” is null

Can someone help?


Can you please share which example are your using? Please share the link of the document so that we can further proceed to assist you accordingly.

public static void main(String[] args) throws Exception {
    // The path to the documents directory.
    String dataDir = Utils.getSharedDataDir(CreateVisioDiagram.class) + "Diagrams/";
    // Create directory if it is not already present.
    File file = new File(dataDir);
    if (!file.exists())
    // initialize a new Diagram

    List<Node> nodeList = buildNodes();

    Diagram diagram = new Diagram();

    PageCollection pages = diagram.getPages();
    Page firstPage = pages.getPage(0);
    int pageId = firstPage.getID();

    String stencilsDir = Utils.getStencilsDir();

    String masterName = "Circle";

    // First, We must add the master to the diagram (from the appropriate stencil file)
    diagram.addMaster(stencilsDir + "Basic Shapes.vssx","Circle");
    diagram.addMaster(stencilsDir + "Blocks.vssx","Dynamic connector");

    int PageIndex = 0;

    double width = 1, height = 1, pinX = 3.25, pinY = 9.5;
    // Add a new process shape
    try {
        long nodeId = diagram.addShape(pinX, pinY, width, height, masterName, PageIndex);
        long nodeId2 = diagram.addShape(pinX+2, pinY-2, width, height, masterName, PageIndex);
        long nodeId3 = diagram.addShape(pinX-2, pinY-2, width, height, masterName, PageIndex);

// connectorShape2.MAKESTRAIGHTLINE <— That is what I don’t know how to do.

        // initialize connector shape
        Shape connectorShape1 = new Shape();

        Shape connectorShape2 = new Shape();

        // add shape
        long connecter1Id = firstPage.addShape(connectorShape1, "Dynamic connector");
        long connecter2Id = firstPage.addShape(connectorShape2, "Dynamic connector");

        // connect sub-shapes
        firstPage.connectShapesViaConnector(nodeId, ConnectionPointPlace.BOTTOM, nodeId2, ConnectionPointPlace.TOP,
        firstPage.connectShapesViaConnector(nodeId, ConnectionPointPlace.BOTTOM, nodeId3, ConnectionPointPlace.TOP,

        // save in the VSDX format
        diagram.save(dataDir + "CreateDiagram2-out.vsdx", SaveFileFormat.VSDX);
    } catch (Exception e)



We only support straight connection lines now.

If you are getting an exception, please share sample files “Basic Shapes.vssx” and “Blocks.vssx” used in your code:

diagram.addMaster(stencilsDir + "Basic Shapes.vssx","Circle");
diagram.addMaster(stencilsDir + "Blocks.vssx","Dynamic connector"); 

I am not getting any exceptions. The lines are appearing. I just don’t want the connectors to have any bends in them. In other words, I want the connectors to always be a straight. I am building a node/edge graph and the connectors cannot have bends in them. I know that Visio supports that in that.

If it helps I can send a small image of what I am trying to achieve.


We will surely check it and share the code snippet with you if it is possible to achieve what you require. Can you please share the sample files i.e. Blocks.vssx and Basic Shapes.vssx for our reference? You can also share the screenshot of what you are trying to achieve.