We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Loop through node collection to retrive the start and end point of all lines.

loop through node collection to retrive the start and end point of all lines.
I need to export these points to a list of X, Y values as coordinates.
I´m using visual basic, so, it you guys can help me I´ll appreciate.

Thanks.

3 Replies

NG Naganathan Ganesh Babu Syncfusion Team June 20, 2016 05:31 AM UTC

Hi Sergio, 
 
Thanks for contacting Syncfusion support. 
 
We have created a sample to achieve your requirement. We suggest you to use Connector’s “GetPoints()” method to get all points of the connectors. Please refer to the below code example and sample. 
 
Code example: 
 
[C#] 
 
Dictionary<string, PointF[]> points = new Dictionary<string, PointF[]>(); 
foreach (Node node in diagram1.Model.Nodes) 
{ 
if (node is ConnectorBase) 
{ 
PointF[] pts = (node as ConnectorBase).GetPoints(); 
points.Add(node.Name, pts); 
} 
} 
 
Sample: 
 
 
Regards, 
 
Naganathan K G 



SR Sérgio Rodrigues Costa June 20, 2016 11:28 AM UTC

I´m sorry if I was not clear enough.
My goal is to translate the diagram to a DXF file, so I have to find out a way to translate at least Rectangles (done ), Text (done), lines (not done yet) and Circles (not done yet).

The sample code that you sent me, its getting similar results to the one I was using. 
Please refer to my attached file to see the results of a simple LineConnector with your sample code.I´m not getting a coordinates pair.

I tought i supposed to get  two coordinates (x,y) from start point and (x1,y1) for the end point.
Thanks again!

Attachment: coordinates_217f3a04.zip


NG Naganathan Ganesh Babu Syncfusion Team June 21, 2016 06:43 AM UTC

Hi Sergio, 
 
Please confirm us whether your requirement is to get the start point and end point of the connector alone? If yes, please use TailEndPoint’s and Headpoint’s “Location” property to get the start and end points of the connector. If we misunderstood your requirement, please share us more information about your requirement probably a code example on how you are getting and saving the diagram’s Rectangle/Text nodes location on the DXF file in your environment, which will help us to analyze further and provide you a better solution. 
 
Also refer to the below attached modified sample and code example: 
 
Code example: 
 
[VB] 
 
Dim line As New LineConnector(New PointF(100, 100), New PointF(200, 100)) 
diagram1.Model.AppendChild(line) 
Dim points As New Dictionary(Of String, PointF())() 
For Each node As Node In diagram1.Model.Nodes 
If TypeOf node Is ConnectorBase Then 
Dim pts(1) As PointF 
'Start point 
pts(0) = (TryCast(node, ConnectorBase)).TailEndPoint.Location 
'End point 
pts(1) = (TryCast(node, ConnectorBase)).HeadEndPoint.Location 
points.Add(node.Name, pts) 
End If 
Next node 
 
Sample: 
 
 
Regards, 
 
Naganathan K G 
 
 


Loader.
Up arrow icon