hbmartin / graphviz2drawio

Convert graphviz (dot) files into draw.io / lucid (mxGraph) format
http://graphviz2drawio.rtfd.io
GNU General Public License v3.0
163 stars 33 forks source link

Exception in MxGraph.add_mx_geo_with_points #61

Closed Zannick closed 5 days ago

Zannick commented 1 year ago

https://github.com/hbmartin/graphviz2drawio/blob/751993505ef02db43ad116e7d4cd38a20608945a/graphviz2drawio/mx/MxGraph.py#L115-L118

Line 117 here throws an exception when curve.cbset is empty, thus leaving cb unset.

kalos92 commented 1 year ago

Correct method as below, seems to work:

@staticmethod
def add_mx_geo_with_points(element, curve):
    geo = ET.SubElement(element, MxConst.GEO, {"as": "geometry"}, relative="1")

    # cbset
    if len(curve.cbset) > 0:
        array = ET.SubElement(geo, MxConst.ARRAY, {"as": "points"})
        for cb in curve.cbset:
            ET.SubElement(array, MxConst.POINT, x=str(cb[0][0]), y=str(cb[0][1]))
            if cb:
                ET.SubElement(array, MxConst.POINT, x=str(cb[1][0]), y=str(cb[1][1]))
andrewchch commented 1 year ago

Can confirm, just encountered this bug and the fix works, thanks!

hbmartin commented 5 days ago

This is fixed in the upcoming 0.3 release. Feel free to reopen or create a new issue if that release does not work as you expect. Thanks for the report!