Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
python-version: "3.11"

- name: Restore cache
id: restore-cache
Expand Down
2 changes: 1 addition & 1 deletion onshape/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.36"
__version__ = "0.2.38"
2 changes: 1 addition & 1 deletion onshape/formats/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def from_json(cls, json_path: Path) -> Self:

def save_xml(
path: str | Path | io.StringIO,
tree: ET.ElementTree[ET.Element | None] | ET.ElementTree[ET.Element] | ET.Element,
tree: ET.ElementTree[ET.Element] | ET.Element,
) -> None:
if isinstance(tree, ET.ElementTree):
root = tree.getroot()
Expand Down
3 changes: 1 addition & 2 deletions onshape/formats/urdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,5 +407,4 @@ def to_xml(self) -> ET.Element:
return robot

def save(self, path: str | Path | io.StringIO) -> None:
tree = ET.ElementTree(self.to_xml())
save_xml(path, tree)
save_xml(path, self.to_xml())
4 changes: 2 additions & 2 deletions onshape/passes/make_convex_collision_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def get_mesh(visual_or_collision: ET.Element) -> tuple[ET.Element, Path] | None:
# make a new mesh for the collision mesh. Otherwise, we can just
# overwrite the existing collision mesh.
if visual_mesh_path == collision_mesh_path:
new_suffix = f"{COLLISION_SUFFIX}{collision_mesh_path.suffix}"
collision_output_mesh_path = collision_mesh_path.with_suffix(new_suffix)
collision_mesh_name = f"{collision_mesh_path.stem}{COLLISION_SUFFIX}{collision_mesh_path.suffix}"
collision_output_mesh_path = collision_mesh_path.parent / collision_mesh_name
collision_mesh_elem.attrib["filename"] = collision_output_mesh_path.relative_to(urdf_path.parent).as_posix()
has_change = True
else:
Expand Down
9 changes: 5 additions & 4 deletions onshape/utils/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

from dataclasses import dataclass
from pathlib import Path
from typing import Any, ClassVar, Literal, Union, cast, get_args
from typing import Any, Literal, Union, cast, get_args

import numpy as np
import trimesh
from numpy.typing import NDArray

MeshType = Literal["stl", "obj"]

COLLISION_SUFFIX = ".collision"
COLLISION_SUFFIX = "_collision"


@dataclass
Expand All @@ -26,13 +26,14 @@ class Mesh:
points: NDArray
faces: NDArray

__hash__: ClassVar[Any] = None # explicit: equal-by-content, not hashable

def __eq__(self, other: Any) -> bool: # noqa: ANN401
if not isinstance(other, Mesh):
return False
return np.allclose(self.points, other.points) and np.array_equal(self.faces, other.faces)

def __hash__(self) -> int:
return hash((self.points, self.faces))

def save(self, file_path: Union[str, Path]) -> None:
save_file(self, file_path)

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ ignore = [
"D101", "D102", "D103", "D104", "D105", "D106", "D107",
"N812", "N817",
"PLR0911", "PLR0912", "PLR0913", "PLR0915", "PLR2004",
"PLW0603", "PLW2901", "PLC0415",
"PLW0603", "PLW2901",
"PLC0415",
]

dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
Expand Down