cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Diagram API Flow Relation Orthogonal Not working

Frequent Contributor

Diagram API Flow Relation Orthogonal Not working

Hi Community,

Am trying to draw a new relation object in the place of a old link. Am able to draw a link but setting the old link drawing points is not working for me. even the old link is in orthogonal, the new link is coming as simple link.  Here is the code:

 

arDrawingLink = FindDrawingLink( oDrawing, oApp1.GetId(), oApp2.GetId(), oOldLeg.GetId())    // Get Old Link

Set oDrawingItem = oDrawingLink.DrawingItem      //Get Drawing Item of old link

 

Set NewFlowRelation = oRoot.getCollection("Flow To Application").Add("Sample Relation 1")  //create new relation object

Set flowdrawingitem = oDrawing.MegaObjectInsert(NewFlowRelation)     //insert new relation in to diagram

Set parentdrawingitem = flowdrawingitem.ItemProperty("ParentDrawingItem")   //get parent drawing item

Set oLineStyle = oDrawingItem.LineStyle    // get old link style
parentdrawingitem.LineStyle = oLineStyle    // apply the style to new relation
parentdrawingitem.ItemProperty("DrwLine_Points") = oDrawingItem.ItemProperty("DrwLine_Points")  //set drawing line points

 

 

 

I think this should work. Is there any thing missed in my code

Colruyt Team
2 Replies
Highlighted
MEGA

Re: Diagram API Flow Relation Orthogonal Not working

Hi Colruyt Team,

 

I'm not familiar with the DIagram API in Vbscript (I've been using Java) but I'm not sure this line works:

 

parentdrawingitem.ItemProperty("DrwLine_Points") = oDrawingItem.ItemProperty("DrwLine_Points")

I would suggest that you try to manually set the points for parentdrawingitem by looping through the points inside oDrawingItem. Do note that each DrawingLine has 2 points by default (If I recall correctly you can't even remove them) so you just need to insert whatever points you have that is neither the start or the end point. Here's some code snippet in Java which might help you figure it out.

 

 

//Draw a line object
DrawingItem drawLineObject = drawing.createDrawingItem("DrwLine", null, null, 1);
DrawingLinePoints points = (DrawingLinePoints) drawLineObject.getItemProperty("DrwLine_Points");
DrawingPen drawPen = drawLineObject.getPen(); drawPen.setDashStyle((short) 1); drawLineObject.setPen(drawPen);
DrawingLineStyle drawLineStyle = drawLineObject.getLineStyle(); //drawLineStyle.setStyle(8); //By default the style is already orthogonal drawLineStyle.setRoundCorner(true); drawLineObject.setLineStyle(drawLineStyle); drawSourceTableObject = drawing.megaObjectInsert(sourceTable); drawSourceTableObject.setPos(sourceTableLeft, sourceTableTop, sourceTableRight, sourceTableBottom); //Adjust the line's starting points points.setAbscissa(0, targetTableLeft + 1000); points.setOrdinate(0, targetTableTop + 300);

//Adjust the line's ending points points.setAbscissa(points.count() - 1, sourceTableLeft + 1000); points.setOrdinate(points.count() - 1, sourceTableTop + 300); //Insert points to reduce collision if (sourceTableTop != targetTableTop) { points.insertPointBefore(points.count() - 1, targetTableLeft + 1000, sourceTableTop + 300); }
drawLineObject.setItemProperty("DrwLine_Points", points);

 

 Gavin

Contributor

Re: Diagram API Flow Relation Orthogonal Not working

Hi,

 

Your original code works fine (i know because i wrote it myself)   :-)

Maybe a    Diagram.Flush   might help ?

 

grtz,

Wim VdV