I'm trying to use EZDXF library to fetch the bounding path of a Hatch as a path made up of subpaths. I'll use this information to create an inline SVG on HTML.
This is the image I'm expecting as seen in LibreCAD.
I printed all the subpaths I'm getting for each Hatch path. Evidently, it's just a single subpath for every hatch.
Code segment dealing with hatches:
elif(i.dxftype() == 'HATCH'):
# <path d="M150 0 L75 200 L225 200 Z" style="fill:black;stroke:black;stroke-width:0.2" />
pathy = ezdxf.path.make_path(i)
firstSubPath = True
fw.write("<path class=\"Hatches\" d=\"M")
print("For a hatch")
for j in pathy.sub_paths():
print(j)
if firstSubPath:
fw.write(str(j.start.x))
fw.write(" ")
fw.write(str(j.start.y))
fw.write(" L")
fw.write(str(j.end.x))
fw.write(" ")
fw.write(str(j.end.y))
fw.write(" ")
else:
fw.write("L")
fw.write(str(j.start.x))
fw.write(" ")
fw.write(str(j.start.y))
fw.write(" ")
fw.write("Z\" style=\"fill:black;stroke:black;stroke-width:0.2\" />\n")
Documentation says that path.make_path(Entity) returns:
HATCH as Multi-Path object
And for multipath object,
the method
Path.sub_paths()yields all paths within this object as single-path objects.
Yet I'm getting a single subpath for every hatch. An example of a hatch path that I generated:
<path class="Hatches" d="M3611.0489658828105 107.74118324488954 L3611.0489658828105 107.74118324488953 Z" style="fill:black;stroke:black;stroke-width:0.2" />
Apparently j.start and j.end have the same coordinates.
Is all of this an issue with the hatch in the dxf itself?