Elminate base class move/rotate when values are zero

This commit is contained in:
Roger Maitland 2026-02-09 10:42:09 -05:00
parent 5c164c0aef
commit 9b87ceae30
2 changed files with 14 additions and 6 deletions

View file

@ -87,14 +87,18 @@ class BasePartObject(Part):
rotate = Rotation(*rotation) if isinstance(rotation, tuple) else rotation
self.rotation = rotate
if context is None:
new_solids = [part.moved(rotate)]
new_solids = [part.moved(rotate)] if rotate != Rotation() else [part]
else:
self.mode = mode
if not LocationList._get_context():
raise RuntimeError("No valid context found")
new_solids = [
part.moved(location * rotate)
(
part.moved(location * rotate)
if rotate != Rotation() or location != Location()
else part
)
for location in LocationList._get_context().locations
]
if isinstance(context, BuildPart):

View file

@ -88,16 +88,20 @@ class BaseSketchObject(Sketch):
context: BuildSketch | None = BuildSketch._get_context(self, log=False)
if context is None:
new_faces = obj.moved(Rotation(0, 0, rotation)).faces()
new_faces = (
obj.moved(Rotation(0, 0, rotation)).faces()
if rotation != 0
else obj.faces()
)
else:
self.rotation = rotation
self.mode = mode
obj = obj.moved(Rotation(0, 0, rotation))
obj = obj.moved(Rotation(0, 0, rotation)) if rotation != 0 else obj
new_faces = ShapeList(
face.moved(location)
face.moved(location) if location != Location() else face
for face in obj.faces()
for location in LocationList._get_context().local_locations
)
@ -550,7 +554,7 @@ class Text(BaseSketchObject):
"Arial Black". Alternatively, a specific font file can be specified with font_path.
Use `available_fonts()` to list available font names for `font` and FontStyles.
Note: on Windows, fonts must be installed with "Install for all users" to be found
Note: on Windows, fonts must be installed with "Install for all users" to be found
by name.
Not all fonts have every FontStyle available, however ITALIC and BOLDITALIC will