Mozman 2
Mozman 2
import ezdxf
from ezdxf.enums import TextEntityAlignment
from ezdxf.addons import text2path
from ezdxf import path
from ezdxf.fonts import fonts
from ezdxf.math import Matrix44
def as_hatches(data):
texto_1 = data["modelo"]["text_1"]
texto_2 = data["modelo"]["text_2"]
doc = ezdxf.new()
msp = doc.modelspace()
ff = fonts.FontFace(family="DejaVu Sans")
fit_into_bbox(
texto_2["text"],
x=float(texto_2["pos"]["x"]),
y=float(texto_2["pos"]["y"]),
width=float(texto_2["size"]["x"]),
height=float(texto_2["size"]["y"]),
)
doc.saveas("hatch-entity.dxf")
def main():
info = {
"basefile": "files/simple_2.dxf",
"filename": "000AAA.dxf",
"quantity": "1",
"modelo": {
"tamanho": {"largura": "80", "altura": "127", "espacamento": "1"},
"text_1": {
"text": "Short Text",
"pos": {"x": "-70", "y": "80"},
"size": {"x": "8", "y": "1"},
},
"text_2": {
"text": "This is an example of long text",
"pos": {"x": "-70", "y": "75"},
"size": {"x": "8", "y": "1"},
},
},
}
as_hatches(info)
if __name__ == "__main__":
main()