Replaced text Halign/Valign with Align

This commit is contained in:
Roger Maitland 2023-01-27 14:23:25 -05:00
parent 2f38545f76
commit d36b120206
14 changed files with 65 additions and 115 deletions

View file

@ -21,7 +21,6 @@ Enums
.. autoclass:: Align .. autoclass:: Align
.. autoclass:: FontStyle .. autoclass:: FontStyle
.. autoclass:: GeomType .. autoclass:: GeomType
.. autoclass:: Halign
.. autoclass:: Keep .. autoclass:: Keep
.. autoclass:: Kind .. autoclass:: Kind
.. autoclass:: Mode .. autoclass:: Mode
@ -29,7 +28,6 @@ Enums
.. autoclass:: SortBy .. autoclass:: SortBy
.. autoclass:: Transition .. autoclass:: Transition
.. autoclass:: Until .. autoclass:: Until
.. autoclass:: Valign
********** **********
Workplanes Workplanes

View file

@ -200,8 +200,6 @@ Cheat Sheet
+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+ +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| :class:`~build_enums.GeomType` | BEZIER, BSPLINE, CIRCLE, CONE, CYLINDER, ELLIPSE, EXTRUSION, HYPERBOLA, LINE, OFFSET, OTHER, PARABOLA, PLANE, REVOLUTION, SPHERE, TORUS | | :class:`~build_enums.GeomType` | BEZIER, BSPLINE, CIRCLE, CONE, CYLINDER, ELLIPSE, EXTRUSION, HYPERBOLA, LINE, OFFSET, OTHER, PARABOLA, PLANE, REVOLUTION, SPHERE, TORUS |
+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+ +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| :class:`~build_enums.Halign` | CENTER, LEFT, RIGHT |
+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| :class:`~build_enums.Keep` | TOP, BOTTOM, BOTH | | :class:`~build_enums.Keep` | TOP, BOTTOM, BOTH |
+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+ +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| :class:`~build_enums.Kind` | ARC, INTERSECTION, TANGENT | | :class:`~build_enums.Kind` | ARC, INTERSECTION, TANGENT |
@ -216,5 +214,3 @@ Cheat Sheet
+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+ +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| :class:`~build_enums.Until` | NEXT, LAST | | :class:`~build_enums.Until` | NEXT, LAST |
+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+ +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| :class:`~build_enums.Valign` | CENTER, TOP, BOTTOM |
+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+

View file

@ -796,10 +796,10 @@ with BuildPart() as ex34:
Box(length, width, thickness) Box(length, width, thickness)
topf = ex34.faces().sort_by(Axis.Z)[-1] topf = ex34.faces().sort_by(Axis.Z)[-1]
with BuildSketch(topf) as ex34_sk: with BuildSketch(topf) as ex34_sk:
Text("Hello", fontsize=fontsz, halign=Halign.CENTER, valign=Valign.BOTTOM) Text("Hello", fontsize=fontsz, align=(Align.CENTER, Align.MIN))
Extrude(amount=fontht) Extrude(amount=fontht)
with BuildSketch(topf) as ex34_sk2: with BuildSketch(topf) as ex34_sk2:
Text("World", fontsize=fontsz, halign=Halign.CENTER, valign=Valign.TOP) Text("World", fontsize=fontsz, align=(Align.CENTER, Align.MAX))
Extrude(amount=-fontht, mode=Mode.SUBTRACT) Extrude(amount=-fontht, mode=Mode.SUBTRACT)
# [Ex. 34] # [Ex. 34]

View file

@ -27,17 +27,22 @@ license:
from build123d import * from build123d import *
with BuildSketch() as logo_text: with BuildSketch() as logo_text:
Text("123d", fontsize=10, valign=Valign.BOTTOM) Text("123d", fontsize=10, align=(Align.MIN, Align.MIN))
font_height = logo_text.vertices().sort_by(Axis.Y)[-1].Y font_height = logo_text.vertices().sort_by(Axis.Y)[-1].Y
with BuildSketch() as build_text: with BuildSketch() as build_text:
Text("build", fontsize=5, halign=Halign.CENTER) Text("build", fontsize=5, align=(Align.CENTER, Align.CENTER))
build_bb = BoundingBox(build_text.sketch, mode=Mode.PRIVATE) build_bb = BoundingBox(build_text.sketch, mode=Mode.PRIVATE)
build_vertices = build_bb.vertices().sort_by(Axis.X) build_vertices = build_bb.vertices().sort_by(Axis.X)
build_width = build_vertices[-1].X - build_vertices[0].X build_width = build_vertices[-1].X - build_vertices[0].X
with BuildSketch() as cust_text: with BuildSketch() as cust_text:
Text("customizable", fontsize=2.9, halign=Halign.CENTER, font_style=FontStyle.BOLD) Text(
"customizable",
fontsize=2.9,
align=(Align.CENTER, Align.CENTER),
font_style=FontStyle.BOLD,
)
cust_bb = BoundingBox(cust_text.sketch, mode=Mode.PRIVATE) cust_bb = BoundingBox(cust_text.sketch, mode=Mode.PRIVATE)
cust_vertices = cust_text.vertices().sort_by(Axis.X) cust_vertices = cust_text.vertices().sort_by(Axis.X)
cust_width = cust_vertices[-1].X - cust_vertices[0].X cust_width = cust_vertices[-1].X - cust_vertices[0].X
@ -48,12 +53,12 @@ with BuildLine() as one:
with BuildSketch() as two: with BuildSketch() as two:
with Locations((font_height * 0.35, 0)): with Locations((font_height * 0.35, 0)):
Text("2", fontsize=10, valign=Valign.BOTTOM) Text("2", fontsize=10, align=(Align.MIN, Align.MIN))
with BuildPart() as three_d: with BuildPart() as three_d:
with Locations((font_height * 1.1, 0)): with Locations((font_height * 1.1, 0)):
with BuildSketch(): with BuildSketch():
Text("3d", fontsize=10, valign=Valign.BOTTOM) Text("3d", fontsize=10, align=(Align.MIN, Align.MIN))
Extrude(amount=font_height * 0.3) Extrude(amount=font_height * 0.3)
logo_width = three_d.vertices().sort_by(Axis.X)[-1].X logo_width = three_d.vertices().sort_by(Axis.X)[-1].X

View file

@ -27,11 +27,11 @@ license:
from build123d import * from build123d import *
with BuildSketch() as logo_text: with BuildSketch() as logo_text:
Text("123d", fontsize=10, valign=Valign.BOTTOM) Text("123d", fontsize=10, align=(Align.MIN, Align.MIN))
font_height = logo_text.vertices().sort_by(Axis.Y)[-1].Y font_height = logo_text.vertices().sort_by(Axis.Y)[-1].Y
with BuildSketch() as build_text: with BuildSketch() as build_text:
Text("build", fontsize=5, halign=Halign.CENTER) Text("build", fontsize=5, align=(Align.CENTER, Align.CENTER))
build_bb = BoundingBox(build_text.sketch, mode=Mode.PRIVATE) build_bb = BoundingBox(build_text.sketch, mode=Mode.PRIVATE)
build_vertices = build_bb.vertices().sort_by(Axis.X) build_vertices = build_bb.vertices().sort_by(Axis.X)
build_width = build_vertices[-1].X - build_vertices[0].X build_width = build_vertices[-1].X - build_vertices[0].X
@ -42,12 +42,12 @@ with BuildLine() as one:
with BuildSketch() as two: with BuildSketch() as two:
with Locations((font_height * 0.35, 0)): with Locations((font_height * 0.35, 0)):
Text("2", fontsize=10, valign=Valign.BOTTOM) Text("2", fontsize=10, align=(Align.MIN, Align.MIN))
with BuildPart() as three_d: with BuildPart() as three_d:
with Locations((font_height * 1.1, 0)): with Locations((font_height * 1.1, 0)):
with BuildSketch(): with BuildSketch():
Text("3d", fontsize=10, valign=Valign.BOTTOM) Text("3d", fontsize=10, align=(Align.MIN, Align.MIN))
Extrude(amount=font_height * 0.3) Extrude(amount=font_height * 0.3)
logo_width = three_d.vertices().sort_by(Axis.X)[-1].X logo_width = three_d.vertices().sort_by(Axis.X)[-1].X

View file

@ -48,7 +48,6 @@ with BuildSketch() as clock_face:
str(hour), str(hour),
fontsize=clock_radius * 0.175, fontsize=clock_radius * 0.175,
font_style=FontStyle.BOLD, font_style=FontStyle.BOLD,
halign=Halign.CENTER,
mode=Mode.SUBTRACT, mode=Mode.SUBTRACT,
) )

View file

@ -30,13 +30,13 @@ from build123d import *
# Extrude pending face by amount # Extrude pending face by amount
with BuildPart() as simple: with BuildPart() as simple:
with BuildSketch(): with BuildSketch():
Text("O", fontsize=10, halign=Halign.CENTER, valign=Valign.CENTER) Text("O", fontsize=10)
Extrude(amount=5) Extrude(amount=5)
# Extrude pending face in both directions by amount # Extrude pending face in both directions by amount
with BuildPart() as both: with BuildPart() as both:
with BuildSketch(): with BuildSketch():
Text("O", fontsize=10, halign=Halign.CENTER, valign=Valign.CENTER) Text("O", fontsize=10)
Extrude(amount=5, both=True) Extrude(amount=5, both=True)
# Extrude multiple pending faces on multiple faces # Extrude multiple pending faces on multiple faces
@ -45,7 +45,7 @@ with BuildPart() as multiple:
with Workplanes(*multiple.faces()): with Workplanes(*multiple.faces()):
with GridLocations(5, 5, 2, 2): with GridLocations(5, 5, 2, 2):
with BuildSketch(): with BuildSketch():
Text("Ω", fontsize=3, halign=Halign.CENTER, valign=Valign.CENTER) Text("Ω", fontsize=3)
Extrude(amount=1) Extrude(amount=1)
# Non-planar surface # Non-planar surface

View file

@ -20,8 +20,6 @@ __all__ = [
"Mode", "Mode",
"Transition", "Transition",
"FontStyle", "FontStyle",
"Halign",
"Valign",
"Until", "Until",
"SortBy", "SortBy",
"GeomType", "GeomType",

View file

@ -41,8 +41,6 @@ from build123d.build_enums import (
Mode, Mode,
Transition, Transition,
FontStyle, FontStyle,
Halign,
Valign,
Until, Until,
SortBy, SortBy,
GeomType, GeomType,

View file

@ -107,28 +107,6 @@ class FontStyle(Enum):
return f"<{self.__class__.__name__}.{self.name}>" return f"<{self.__class__.__name__}.{self.name}>"
class Halign(Enum):
"""Text Horizontal Alignment"""
CENTER = auto()
LEFT = auto()
RIGHT = auto()
def __repr__(self):
return f"<{self.__class__.__name__}.{self.name}>"
class Valign(Enum):
"""Text Vertical Alignment"""
CENTER = auto()
TOP = auto()
BOTTOM = auto()
def __repr__(self):
return f"<{self.__class__.__name__}.{self.name}>"
class Until(Enum): class Until(Enum):
"""Extrude limit""" """Extrude limit"""

View file

@ -42,7 +42,7 @@ import inspect
from math import pi, sin, cos, tan, radians from math import pi, sin, cos, tan, radians
from typing import Union from typing import Union
from build123d.hull import find_hull from build123d.hull import find_hull
from build123d.build_enums import Align, CenterOf, FontStyle, Halign, Mode, Valign from build123d.build_enums import Align, CenterOf, FontStyle, Mode
from build123d.direct_api import ( from build123d.direct_api import (
Edge, Edge,
Wire, Wire,
@ -722,7 +722,7 @@ class SlotOverall(BaseSketchObject):
super().__init__(face, rotation, None, mode) super().__init__(face, rotation, None, mode)
class Text(Compound): class Text(BaseSketchObject):
"""Sketch Object: Text """Sketch Object: Text
Add text(s) to the sketch. Add text(s) to the sketch.
@ -733,8 +733,8 @@ class Text(Compound):
font (str, optional): font name. Defaults to "Arial". font (str, optional): font name. Defaults to "Arial".
font_path (str, optional): system path to font library. Defaults to None. font_path (str, optional): system path to font library. Defaults to None.
font_style (Font_Style, optional): style. Defaults to Font_Style.REGULAR. font_style (Font_Style, optional): style. Defaults to Font_Style.REGULAR.
halign (Halign, optional): horizontal alignment. Defaults to Halign.LEFT. align (tuple[Align, Align], optional): align min, center, or max of object.
valign (Valign, optional): vertical alignment. Defaults to Valign.CENTER. Defaults to (Align.CENTER, Align.CENTER).
path (Union[Edge, Wire], optional): path for text to follow. Defaults to None. path (Union[Edge, Wire], optional): path for text to follow. Defaults to None.
position_on_path (float, optional): the relative location on path to position the position_on_path (float, optional): the relative location on path to position the
text, values must be between 0.0 and 1.0. Defaults to 0.0. text, values must be between 0.0 and 1.0. Defaults to 0.0.
@ -751,8 +751,7 @@ class Text(Compound):
font: str = "Arial", font: str = "Arial",
font_path: str = None, font_path: str = None,
font_style: FontStyle = FontStyle.REGULAR, font_style: FontStyle = FontStyle.REGULAR,
halign: Halign = Halign.LEFT, align: tuple[Align, Align] = (Align.CENTER, Align.CENTER),
valign: Valign = Valign.CENTER,
path: Union[Edge, Wire] = None, path: Union[Edge, Wire] = None,
position_on_path: float = 0.0, position_on_path: float = 0.0,
rotation: float = 0, rotation: float = 0,
@ -767,8 +766,7 @@ class Text(Compound):
self.font = font self.font = font
self.font_path = font_path self.font_path = font_path
self.font_style = font_style self.font_style = font_style
self.halign = halign self.align = align
self.valign = valign
self.text_path = path self.text_path = path
self.position_on_path = position_on_path self.position_on_path = position_on_path
self.rotation = rotation self.rotation = rotation
@ -780,19 +778,11 @@ class Text(Compound):
font=font, font=font,
font_path=font_path, font_path=font_path,
font_style=font_style, font_style=font_style,
halign=halign, align=align,
valign=valign,
position_on_path=position_on_path, position_on_path=position_on_path,
text_path=path, text_path=path,
).rotate(Axis.Z, rotation) )
new_compounds = [ super().__init__(text_string, rotation, None, mode)
text_string.moved(location)
for location in LocationList._get_context().local_locations
]
new_faces = [face for compound in new_compounds for face in compound]
for face in new_faces:
context._add_to_context(face, mode=mode)
super().__init__(Compound.make_compound(new_faces).wrapped)
class Trapezoid(BaseSketchObject): class Trapezoid(BaseSketchObject):

View file

@ -65,7 +65,7 @@ from typing_extensions import Literal
from vtkmodules.vtkCommonDataModel import vtkPolyData from vtkmodules.vtkCommonDataModel import vtkPolyData
from vtkmodules.vtkFiltersCore import vtkPolyDataNormals, vtkTriangleFilter from vtkmodules.vtkFiltersCore import vtkPolyDataNormals, vtkTriangleFilter
from build123d.build_enums import Until from build123d.build_enums import Align, Until
import OCP.GeomAbs as ga # Geometry type enum import OCP.GeomAbs as ga # Geometry type enum
import OCP.IFSelect import OCP.IFSelect
@ -262,12 +262,10 @@ from build123d.build_enums import (
FontStyle, FontStyle,
FrameMethod, FrameMethod,
GeomType, GeomType,
Halign,
Kind, Kind,
PositionMode, PositionMode,
SortBy, SortBy,
Transition, Transition,
Valign,
) )
# Create a build123d logger to distinguish these logs from application logs. # Create a build123d logger to distinguish these logs from application logs.
@ -3489,7 +3487,7 @@ class Shape(NodeMixin):
font: str = "Arial", font: str = "Arial",
font_path: str = None, font_path: str = None,
kind: FontStyle = FontStyle.REGULAR, kind: FontStyle = FontStyle.REGULAR,
valign: Valign = Valign.CENTER, valign: Align = Align.CENTER,
start: float = 0, start: float = 0,
) -> Compound: ) -> Compound:
"""Projected 3D text following the given path on Shape """Projected 3D text following the given path on Shape
@ -3512,7 +3510,7 @@ class Shape(NodeMixin):
font: Font name. Defaults to "Arial". font: Font name. Defaults to "Arial".
font_path: Path to font file. Defaults to None. font_path: Path to font file. Defaults to None.
kind: Font type. Defaults to FontStyle.REGULAR. kind: Font type. Defaults to FontStyle.REGULAR.
valign: Vertical Alignment. Defaults to Valign.CENTER. valign: Vertical Alignment. Defaults to Align.CENTER.
start: Relative location on path to start the text. Defaults to 0. start: Relative location on path to start the text. Defaults to 0.
Returns: Returns:
@ -3525,7 +3523,7 @@ class Shape(NodeMixin):
# Create text faces # Create text faces
text_faces = Compound.make_2d_text( text_faces = Compound.make_2d_text(
txt, fontsize, font, font_path, kind, Halign.LEFT, valign, start txt, fontsize, font, font_path, kind, (Align.MIN, valign), start
).faces() ).faces()
logger.debug("projecting text sting '%s' as %d face(s)", txt, len(text_faces)) logger.debug("projecting text sting '%s' as %d face(s)", txt, len(text_faces))
@ -4515,8 +4513,7 @@ class Compound(Shape, Mixin3D):
font: str = "Arial", font: str = "Arial",
font_path: str = None, font_path: str = None,
kind: FontStyle = FontStyle.REGULAR, kind: FontStyle = FontStyle.REGULAR,
halign: Halign = Halign.CENTER, align: tuple[Align, Align] = (Align.CENTER, Align.CENTER),
valign: Valign = Valign.CENTER,
position: Plane = Plane.XY, position: Plane = Plane.XY,
) -> Compound: ) -> Compound:
"""3D text """3D text
@ -4530,15 +4527,15 @@ class Compound(Shape, Mixin3D):
font (str, optional): font type. Defaults to "Arial". font (str, optional): font type. Defaults to "Arial".
font_path (str, optional): system path to fonts. Defaults to None. font_path (str, optional): system path to fonts. Defaults to None.
kind (FontStyle, optional): font style. Defaults to FontStyle.REGULAR. kind (FontStyle, optional): font style. Defaults to FontStyle.REGULAR.
halign (Halign, optional): horizontal alignment. Defaults to Halign.CENTER. align (tuple[Align, Align], optional): align min, center, or max of object.
valign (Valign, optional): vertical alignment. Defaults to Valign.CENTER. Defaults to (Align.CENTER, Align.CENTER).
position (Plane, optional): plane to position text. Defaults to Plane.XY. position (Plane, optional): plane to position text. Defaults to Plane.XY.
Returns: Returns:
Compound: 3d text Compound: 3d text
""" """
text_flat = Compound.make_2d_text( text_flat = Compound.make_2d_text(
text, size, font, font_path, kind, halign, valign, None text, size, font, font_path, kind, align, None
) )
vec_normal = text_flat.faces()[0].normal_at() * height vec_normal = text_flat.faces()[0].normal_at() * height
@ -4556,8 +4553,7 @@ class Compound(Shape, Mixin3D):
font: str = "Arial", font: str = "Arial",
font_path: Optional[str] = None, font_path: Optional[str] = None,
font_style: FontStyle = FontStyle.REGULAR, font_style: FontStyle = FontStyle.REGULAR,
halign: Halign = Halign.LEFT, align: tuple[Align, Align] = (Align.CENTER, Align.CENTER),
valign: Valign = Valign.CENTER,
position_on_path: float = 0.0, position_on_path: float = 0.0,
text_path: Union[Edge, Wire] = None, text_path: Union[Edge, Wire] = None,
) -> "Compound": ) -> "Compound":
@ -4574,8 +4570,8 @@ class Compound(Shape, Mixin3D):
font: font name font: font name
font_path: path to font file font_path: path to font file
font_style: text style. Defaults to FontStyle.REGULAR. font_style: text style. Defaults to FontStyle.REGULAR.
halign: horizontal alignment. Defaults to Halign.LEFT. align (tuple[Align, Align], optional): align min, center, or max of object.
valign: vertical alignment. Defaults to Valign.CENTER. Defaults to (Align.CENTER, Align.CENTER).
position_on_path: the relative location on path to position the text, position_on_path: the relative location on path to position the text,
between 0.0 and 1.0. Defaults to 0.0. between 0.0 and 1.0. Defaults to 0.0.
text_path: a path for the text to follows. Defaults to None - linear text. text_path: a path for the text to follows. Defaults to None - linear text.
@ -4643,21 +4639,17 @@ class Compound(Shape, Mixin3D):
) )
text_flat = Compound(builder.Perform(font_i, NCollection_Utf8String(txt))) text_flat = Compound(builder.Perform(font_i, NCollection_Utf8String(txt)))
bounding_box = text_flat.bounding_box() # Align the text from the bounding box
bbox = text_flat.bounding_box()
center_alignment = Vector() align_offset = []
for i in range(2):
if halign == Halign.CENTER: if align[i] == Align.MIN:
center_alignment.X = -bounding_box.xlen / 2 align_offset.append(-bbox.mins[i])
elif halign == Halign.RIGHT: elif align[i] == Align.CENTER:
center_alignment.X = -bounding_box.xlen align_offset.append(-(bbox.mins[i] + bbox.maxs[i]) / 2)
elif align[i] == Align.MAX:
if valign == Valign.CENTER: align_offset.append(-bbox.maxs[i])
center_alignment.Y = -bounding_box.ylen / 2 text_flat = text_flat.translate(Vector(*align_offset))
elif valign == Valign.TOP:
center_alignment.Y = -bounding_box.ylen
text_flat = text_flat.translate(center_alignment)
if text_path is not None: if text_path is not None:
path_length = text_path.length path_length = text_path.length
@ -7302,14 +7294,14 @@ class SVG:
arrow = arrow_arc.fuse(arrow_arc.copy().mirror(Plane.XZ)) arrow = arrow_arc.fuse(arrow_arc.copy().mirror(Plane.XZ))
x_label = ( x_label = (
Compound.make_2d_text( Compound.make_2d_text(
"X", fontsize=axes_scale / 4, halign=Halign.LEFT, valign=Valign.CENTER "X", fontsize=axes_scale / 4, align=(Align.MIN, Align.CENTER)
) )
.move(Location(x_axis @ 1)) .move(Location(x_axis @ 1))
.edges() .edges()
) )
y_label = ( y_label = (
Compound.make_2d_text( Compound.make_2d_text(
"Y", fontsize=axes_scale / 4, halign=Halign.LEFT, valign=Valign.CENTER "Y", fontsize=axes_scale / 4, align=(Align.MIN, Align.CENTER)
) )
.rotate(Axis.Z, 90) .rotate(Axis.Z, 90)
.move(Location(y_axis @ 1)) .move(Location(y_axis @ 1))
@ -7317,10 +7309,7 @@ class SVG:
) )
z_label = ( z_label = (
Compound.make_2d_text( Compound.make_2d_text(
"Z", "Z", fontsize=axes_scale / 4, align=(Align.CENTER, Align.MIN)
fontsize=axes_scale / 4,
halign=Halign.CENTER,
valign=Valign.BOTTOM,
) )
.rotate(Axis.Y, 90) .rotate(Axis.Y, 90)
.rotate(Axis.X, 90) .rotate(Axis.X, 90)
@ -8052,15 +8041,15 @@ class BallJoint(Joint):
circle_x, circle_x,
circle_y, circle_y,
circle_z, circle_z,
Compound.make_2d_text("X", radius / 5, halign=Halign.CENTER).locate( Compound.make_2d_text(
circle_x.location_at(0.125) * Rotation(90, 0, 0) "X", radius / 5, align=(Align.CENTER, Align.CENTER)
), ).locate(circle_x.location_at(0.125) * Rotation(90, 0, 0)),
Compound.make_2d_text("Y", radius / 5, halign=Halign.CENTER).locate( Compound.make_2d_text(
circle_y.location_at(0.625) * Rotation(90, 0, 0) "Y", radius / 5, align=(Align.CENTER, Align.CENTER)
), ).locate(circle_y.location_at(0.625) * Rotation(90, 0, 0)),
Compound.make_2d_text("Z", radius / 5, halign=Halign.CENTER).locate( Compound.make_2d_text(
circle_z.location_at(0.125) * Rotation(90, 0, 0) "Z", radius / 5, align=(Align.CENTER, Align.CENTER)
), ).locate(circle_z.location_at(0.125) * Rotation(90, 0, 0)),
] ]
).move(self.parent.location * self.relative_location) ).move(self.parent.location * self.relative_location)

View file

@ -230,8 +230,7 @@ class BuildSketchObjects(unittest.TestCase):
self.assertEqual(t.font, "Arial") self.assertEqual(t.font, "Arial")
self.assertIsNone(t.font_path) self.assertIsNone(t.font_path)
self.assertEqual(t.font_style, FontStyle.REGULAR) self.assertEqual(t.font_style, FontStyle.REGULAR)
self.assertEqual(t.halign, Halign.LEFT) self.assertEqual(t.align, (Align.CENTER, Align.CENTER))
self.assertEqual(t.valign, Valign.CENTER)
self.assertIsNone(t.text_path) self.assertIsNone(t.text_path)
self.assertEqual(t.position_on_path, 0) self.assertEqual(t.position_on_path, 0)
self.assertEqual(t.rotation, 0) self.assertEqual(t.rotation, 0)

View file

@ -427,7 +427,7 @@ class TestCompound(unittest.TestCase):
text = Compound.make_2d_text("test", 10, text_path=arc) text = Compound.make_2d_text("test", 10, text_path=arc)
self.assertEqual(len(text.faces()), 4) self.assertEqual(len(text.faces()), 4)
text = Compound.make_2d_text( text = Compound.make_2d_text(
"test", 10, halign=Halign.RIGHT, valign=Valign.TOP, text_path=arc "test", 10, align=(Align.MAX,Align.MAX), text_path=arc
) )
self.assertEqual(len(text.faces()), 4) self.assertEqual(len(text.faces()), 4)
@ -1274,7 +1274,7 @@ class ProjectionTests(unittest.TestCase):
sphere = Solid.make_sphere(50) sphere = Solid.make_sphere(50)
projection_direction = Vector(0, -1, 0) projection_direction = Vector(0, -1, 0)
planar_text_faces = ( planar_text_faces = (
Compound.make_2d_text("Flat", 30, halign=Halign.CENTER) Compound.make_2d_text("Flat", 30, align=(Align.CENTER, Align.CENTER))
.rotate(Axis.X, 90) .rotate(Axis.X, 90)
.faces() .faces()
) )