pt to mm
This commit is contained in:
parent
4b75ecb803
commit
288081ddf0
3 changed files with 8 additions and 6 deletions
|
|
@ -373,7 +373,7 @@ class SLICENODE_MeshToPdf(ExecSliceNode):
|
||||||
show_bbox_size: NfBoolProperty(name="Bounding Box Sizes", default=False) # pyright: ignore[reportInvalidTypeForm]
|
show_bbox_size: NfBoolProperty(name="Bounding Box Sizes", default=False) # pyright: ignore[reportInvalidTypeForm]
|
||||||
|
|
||||||
line_width: NfFloatProperty(name="Line Width (mm)", default=0.0, min=0.0, max=50.0) # pyright: ignore[reportInvalidTypeForm]
|
line_width: NfFloatProperty(name="Line Width (mm)", default=0.0, min=0.0, max=50.0) # pyright: ignore[reportInvalidTypeForm]
|
||||||
font_size: NfFloatProperty(name="Font Size (pt)", default=0.0, min=0.0, max=100.0) # pyright: ignore[reportInvalidTypeForm]
|
font_size: NfFloatProperty(name="Font Size (mm)", default=0.0, min=0.0, max=100.0) # pyright: ignore[reportInvalidTypeForm]
|
||||||
margin: NfFloatProperty(name="Margin (mm)", default=10.0, min=0.0, max=500.0) # pyright: ignore[reportInvalidTypeForm]
|
margin: NfFloatProperty(name="Margin (mm)", default=10.0, min=0.0, max=500.0) # pyright: ignore[reportInvalidTypeForm]
|
||||||
|
|
||||||
bg_color: NfFloatVectorProperty(
|
bg_color: NfFloatVectorProperty(
|
||||||
|
|
@ -508,7 +508,7 @@ class SLICENODE_MeshToPdf(ExecSliceNode):
|
||||||
crease_angle=self.crease_angle,
|
crease_angle=self.crease_angle,
|
||||||
margin_mm=self.margin,
|
margin_mm=self.margin,
|
||||||
line_width_mm=self.line_width,
|
line_width_mm=self.line_width,
|
||||||
font_size_pt=self.font_size,
|
font_size_mm=self.font_size * 2.834645669291339,
|
||||||
stroke_color=(float(self.wire_color[0]), float(self.wire_color[1]), float(self.wire_color[2])),
|
stroke_color=(float(self.wire_color[0]), float(self.wire_color[1]), float(self.wire_color[2])),
|
||||||
bg_color=(float(self.bg_color[0]), float(self.bg_color[1]), float(self.bg_color[2])),
|
bg_color=(float(self.bg_color[0]), float(self.bg_color[1]), float(self.bg_color[2])),
|
||||||
bbox_color=(float(self.bbox_color[0]), float(self.bbox_color[1]), float(self.bbox_color[2])),
|
bbox_color=(float(self.bbox_color[0]), float(self.bbox_color[1]), float(self.bbox_color[2])),
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ def export_mesh_to_pdf(
|
||||||
crease_angle: float = 30.0,
|
crease_angle: float = 30.0,
|
||||||
margin_mm: float = 10.0,
|
margin_mm: float = 10.0,
|
||||||
line_width_mm: float = 0.5,
|
line_width_mm: float = 0.5,
|
||||||
font_size_pt: float | None = None,
|
font_size_mm: float = 0.0,
|
||||||
stroke_color: tuple[float, float, float] = (0.0, 0.0, 0.0),
|
stroke_color: tuple[float, float, float] = (0.0, 0.0, 0.0),
|
||||||
bg_color: tuple[float, float, float] = (1.0, 1.0, 1.0),
|
bg_color: tuple[float, float, float] = (1.0, 1.0, 1.0),
|
||||||
bbox_color: tuple[float, float, float] = (0.0, 0.0, 1.0),
|
bbox_color: tuple[float, float, float] = (0.0, 0.0, 1.0),
|
||||||
|
|
@ -211,9 +211,11 @@ def export_mesh_to_pdf(
|
||||||
else:
|
else:
|
||||||
line_width_pt = line_width_mm * MM_TO_PT
|
line_width_pt = line_width_mm * MM_TO_PT
|
||||||
|
|
||||||
# Automatic font size: equal to minor grid spacing
|
# Convert font_size_mm to pt and apply multiplier
|
||||||
if font_size_pt is None or font_size_pt <= 0:
|
if font_size_mm <= 0:
|
||||||
font_size_pt = minor_step * MM_TO_PT
|
font_size_pt = minor_step * MM_TO_PT
|
||||||
|
else:
|
||||||
|
font_size_pt = font_size_mm * MM_TO_PT
|
||||||
|
|
||||||
def to_pdf_pt(pt_mm: NDArray[np.float64]) -> NDArray[np.float64]:
|
def to_pdf_pt(pt_mm: NDArray[np.float64]) -> NDArray[np.float64]:
|
||||||
x_pt = (pt_mm[:, 0] - grid_min_x + total_margin_mm) * MM_TO_PT
|
x_pt = (pt_mm[:, 0] - grid_min_x + total_margin_mm) * MM_TO_PT
|
||||||
|
|
|
||||||
|
|
@ -677,7 +677,7 @@ class TestPdfExporter(unittest.TestCase):
|
||||||
export_mesh_to_pdf(
|
export_mesh_to_pdf(
|
||||||
edges_2d,
|
edges_2d,
|
||||||
pdf_path,
|
pdf_path,
|
||||||
font_size_pt=14.5,
|
font_size_mm=5.12,
|
||||||
show_name=True,
|
show_name=True,
|
||||||
raw_geometry=so
|
raw_geometry=so
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue