Java; I am am able to draw the Visio diagram with code by using the Dynamic connector property. I want draw diagram with straight lines rather than Dynamic is that possible. Is there any property like straight lines or any way??
I have attached the image with this as well
Straight line.png (17.5 KB)
dynamic connector.png (3.4 KB)
@ryan.padovani
Thanks for the screenshots.
Please try this sample code:
shape.setConnectorsType(ConnectorsTypeValue.STRAIGHT_LINES);
Thanks.
I had tried that but that dose not worked at all. No effect on diagram.
@ryan.padovani
Could you please share your sample code and file that you are using?
Here is my complete (runnable) sample code for your reference,It works fine and as expected:
Please find attached the input and output for your reference.
files.zip (11.3 KB)
Diagram map = new Diagram( "Drawing11.vsdx");
// Get a particular page
Page page = map.getPages().getPage("Page-3");
// Get a dynamic connector type shape by id
Shape shape = page.getShapes().getShape(18);
// Set dynamic connector appearance
shape.setConnectorsType(ConnectorsTypeValue.STRAIGHT_LINES);
// Saving Visio diagram
map.save( "output.vsdx", SaveFileFormat.VSDX);
We are generating visio from scratch to load shapes and for connectors I am using attached stencils file. And I am using only Dynamic Connector form it. Rest of the code is same. Do I need to use some different stencils to get the straight line?
image.png (4.0 KB)
@ryan.padovani
Thanks for the screenshots.
Could you please share the stencils file?
We will check it soon.
Thanks.
I need to take some permission from my team first. But meanwhile I can attached the screen shots of files. Could you please share any simple sample working code with me? I need to run that locally first. Also please share the updated stencils files with me if there are any. Blocks & BasicShapes.vssx files.
image.png (18.5 KB)
image.png (29.4 KB)
@ryan.padovani
Please refer to this sample code:
String directory = "yourpath";
Diagram myDiagram = new Diagram();
myDiagram.addMaster(directory + "BasicShapes.vssx", "Rectangle");
myDiagram.addMaster(directory + "BasicShapes.vssx", "Dynamic connector");
Page myPage = myDiagram.getPages().getPage(0);
long rectangleID = myPage.addShape(3, 8, "Rectangle");
Shape rectangle = myPage.getShapes().getShape(rectangleID);
long rectangle2ID = myPage.addShape(6, 4, "Rectangle");
Shape rectangle2 = myPage.getShapes().getShape(rectangle2ID);
long connectorID = myPage.addShape(1, 1, "Dynamic connector");
Shape connector = myPage.getShapes().getShape(connectorID);
myPage.connectShapesViaConnector(rectangleID, ConnectionPointPlace.RIGHT, rectangle2ID, ConnectionPointPlace.LEFT, connectorID);
connector.setConnectorsType(ConnectorsTypeValue.STRAIGHT_LINES);
// Saving Visio diagram
myDiagram.save( "output.vsdx", SaveFileFormat.VSDX);
@ryan.padovani
Please find attached the vssx file for your reference.
BasicShapes.zip (59.3 KB)
Thanks.