Added closed exploded letters into design (R12 and closed polylines) #993
-
Hello! I am trying to use ezdxf to create a silicon photolithography mask, and the tool requires both the R12 format and all lines to be closed. This means that the text that I want in the file needs to be exploded. I have tried many things, and am just not able to figure this last step out. The closest I have gotten was this: import ezdxf
from ezdxf.fonts import fonts
from ezdxf import path
from ezdxf.addons import text2path
import logging
logging.basicConfig(level=logging.INFO)
doc = ezdxf.new(dxfversion=ezdxf.DXF12)
msp = doc.modelspace()
ff = fonts.FontFace(family="Courier New")
path_object = text2path.make_path_from_str("Hello World!", ff, size=100)
path.render_splines_and_polylines(msp, path_object)
doc.saveas("textpath.dxf") which seems to work except that when I set the doc to R12 the letters are messed up and the shapes are not closed polylines. Any help would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
-
I have good and bad news for you:
from string import ascii_letters
import ezdxf
from ezdxf.fonts import fonts
from ezdxf import path
from ezdxf.addons import text2path
doc = ezdxf.new(dxfversion=ezdxf.DXF12)
msp = doc.modelspace()
ff = fonts.FontFace(family="JetBrains Mono")
text_path = text2path.make_path_from_str(ascii_letters + "0§$%&", ff, size=100)
for char in path.group_paths(path.single_paths([text_path])):
vertices = []
for subpath in char:
# each subpath is a closed loop!
# the end point and the start point of consecutive paths are connected
vertices.extend(subpath.flattening(distance=1))
msp.add_polyline2d(vertices)
doc.saveas("textpath_r12.dxf") |
Beta Was this translation helpful? Give feedback.
I have good and bad news for you:
path.render_splines_and_polylines()
function and therefore noSPLINE
entities andr12export
moduleezdxf
has the tools to group the paths of a letter into a single polyline