dave-howard / vsdx

vsdx - A python library for processing .vsdx files
BSD 3-Clause "New" or "Revised" License
70 stars 25 forks source link

get the connector #3

Closed john012343210 closed 3 years ago

john012343210 commented 3 years ago

thanks for the 3 test vsdx and the well written test file.

May I know how to get the connection information from vsdx?

james-powis commented 3 years ago

I too was wondering this.

Testing from Lucid chart, the CSV export contains connections, but when exporting as vsdx and importing back in to lucid chart, all the relevant information I am looking to retain is present EXCEPT connections are no longer snapped to the shapes.

This is either a manifestation of the vsdx format, or import. Any guidance would be greatly appreciated.

james-powis commented 3 years ago

OK I have delved into the VSDX file format... There is no actual data construct which "snaps" the line to the object.

Basically you have the Shapes XY coordinates, as well as heigh and width. You also have a start xy and end xy for each of the line shapes.

I suspect it is as simple as getting each of the shapes, compute the edge boundry, and then check each line to see if it's start or end coordinates are on the edge of the shape.

john012343210 commented 3 years ago

"I suspect it is as simple as getting each of the shapes, compute the edge boundry, and then check each line to see if it's start or end coordinates are on the edge of the shape."

This is a possible guess, as I am sure that a line is also a shape, they probably just check whether the boundary of the line touches any shape.........

Of course, I am not 100% sure.

john012343210 commented 3 years ago

OK I have delved into the VSDX file format... There is no actual data construct which "snaps" the line to the object.

Basically you have the Shapes XY coordinates, as well as heigh and width. You also have a start xy and end xy for each of the line shapes.

I suspect it is as simple as getting each of the shapes, compute the edge boundry, and then check each line to see if it's start or end coordinates are on the edge of the shape.

actually if we try to read the source code of drawio, we might know how to get the connecting information, since drawio accepts import vsdx format graph, and drawio could perfectly read that connection information such that when you drag some shape, the connected line with other shapes will move too. However, the source code base is huge. I couldn't even locate where does this import function exist.

james-powis commented 3 years ago

I am still digging into this, #4 is a bit of a bigger issue as right now this module does not properly implement the masters files which are used for deduplication within the file format. Basically shapes can be defined in the page directly, or they can be defined in master and then referenced within the page with overrides. Its pretty a ingenious solution, and it uses the same methodology of the pages directory. I hope to have something soon which that specific limitation. Then I will look into solving for the connector issue.

dave-howard commented 3 years ago

Hi - I think you are both right on the connectors/line shapes. There is a relationship defined in Connects/Connect element and the module should move the line shapes that are mapped to any other shape that are being moved (I imagine it will be more complex than that but its a start). Regards master files - you are right, I have not needed to look at that element.

dave-howard commented 3 years ago

Hi - I have add a couple of properties to Shape class. Shape.connected_shapes provides list of Shape objects (so connectors, or shapes if you query the connector) Shape.connects provides a list of Connect objects which describe the relationship

v0.2.5 pushed to PyPI now

I hope that helps address the initial question :)

I'll leave this issue open for now in case it doesn't.

dave-howard commented 3 years ago

Closing after v0.2.5 push