python-cad-tools 0.1.29__py3-none-any.whl → 0.1.30__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,12 +28,13 @@ from typing import Any
28
28
  from .determinism import semantic_hash
29
29
  from .elements import DesignElement, DesignModel
30
30
  from .exceptions import ArtifactIntegrityError
31
+ from .geometry import bounds
31
32
  from .units import format_feet_inches
32
33
 
33
34
  SCHEMA_ID = "urn:python-cad-tools:schema:inventory:1"
34
35
  SCHEMA_VERSION = 1
35
36
  #: Bumped whenever a rule that changes parts or lines changes. Consumers refuse a newer one.
36
- CALCULATION_VERSION = 1
37
+ CALCULATION_VERSION = 2
37
38
  ASSUMPTIONS = {"waste": "none", "rounding": "none", "stock_sizes": "none"}
38
39
  #: A declared box smaller than the solid by more than this fraction is not the part's size.
39
40
  _DIMENSION_TOLERANCE = 0.001
@@ -168,8 +169,8 @@ def _part_record(element: DesignElement, by_id: Mapping[str, DesignElement]) ->
168
169
  "category": element.category,
169
170
  "parent_id": element.parent_id,
170
171
  "assembly_path": list(reversed(path)),
171
- "description": declared_description or element.name,
172
- "description_source": "declared" if declared_description else "element_name",
172
+ "description": declared_description or _generic_description(material.name, element.category),
173
+ "description_source": "declared" if declared_description else "material_and_category",
173
174
  "material": {"id": material.id, "name": material.name, "category": material.category},
174
175
  "specification": specification,
175
176
  "kind": kind,
@@ -184,6 +185,17 @@ def _part_record(element: DesignElement, by_id: Mapping[str, DesignElement]) ->
184
185
  return record
185
186
 
186
187
 
188
+ def _generic_description(material_name: str, category: str) -> str:
189
+ """An undeclared part is described by what it is made of and what it is for, never by its
190
+ unique element name, so identical undeclared parts still share a line."""
191
+ words = category.replace("-", " ").replace("_", " ").strip()
192
+ return f"{material_name} {words}".strip() if words and words.lower() not in material_name.lower() else material_name
193
+
194
+
195
+ def _boxes_overlap(first: tuple[float, ...], second: tuple[float, ...]) -> bool:
196
+ return all(first[i] < second[i + 3] and second[i] < first[i + 3] for i in range(3))
197
+
198
+
187
199
  def _flag_parent_overlaps(parts: list[dict[str, Any]], by_id: Mapping[str, DesignElement]) -> None:
188
200
  """A physical parent whose solid also covers a physical child's solid would count that
189
201
  material twice; mark both as unresolved rather than silently dropping either."""
@@ -196,8 +208,12 @@ def _flag_parent_overlaps(parts: list[dict[str, Any]], by_id: Mapping[str, Desig
196
208
  child_volume = float(child_solid.volume)
197
209
  if child_volume <= 0:
198
210
  continue
211
+ if not _boxes_overlap(bounds(parent_solid), bounds(child_solid)):
212
+ continue
199
213
  try:
200
- shared = float((parent_solid & child_solid).volume)
214
+ common = parent_solid & child_solid
215
+ # build123d returns None when the solids share no volume.
216
+ shared = 0.0 if common is None else float(common.volume)
201
217
  except Exception: # noqa: BLE001 - a failed boolean cannot prove the parts are separate
202
218
  shared = child_volume
203
219
  if shared > child_volume * _OVERLAP_FRACTION:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-cad-tools
3
- Version: 0.1.29
3
+ Version: 0.1.30
4
4
  Summary: Typed, headless Python tooling for CAD/BIM models and artifacts
5
5
  Author: Brandon Benge
6
6
  License: AGPL-3.0-only
@@ -15,7 +15,7 @@ python_cad_tools/determinism.py,sha256=HFXNl9Uje6prAuGoLQ3WWaiSDuF1gYyi7l7fxU_nR
15
15
  python_cad_tools/elements.py,sha256=Pvh1l2RmzAxpY6cPimL2gkegX68EFDkaJHwCkDEainM,5943
16
16
  python_cad_tools/exceptions.py,sha256=0GWY2-Hgv2fJHIOsN5UHutmQn4kDsFaQuQI-fRHVjLo,1115
17
17
  python_cad_tools/geometry.py,sha256=OL3WC36RbUGPiShuoEsFTthndDTtd7pM6v5yWl7cct8,11114
18
- python_cad_tools/inventory.py,sha256=DX6zwy59Ni2ulnHh4ap-rVhT-LJCdNQwysGaM_H9bBI,27577
18
+ python_cad_tools/inventory.py,sha256=XFFwpDdJuAfXpFiqty7-R-vnyfJ0pHjh_p_X1LCCkwo,28473
19
19
  python_cad_tools/manifests.py,sha256=o415rWLEXcQb8J7c0vALNHzdVQvjROCOk3K25hG79E0,19115
20
20
  python_cad_tools/project_config.py,sha256=5fhAyhqbALFxTNFkYavo5ZKXxK6xklQf0Vh7VVdxfqU,7032
21
21
  python_cad_tools/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
@@ -235,9 +235,9 @@ python_cad_tools/templates/project/config.py,sha256=nhzK6fQJkzlA7qr6gU4NgC92QghW
235
235
  python_cad_tools/templates/project/drawing_annotations.py,sha256=6OY7qQUGtCV2sl-hjBKHABKvgcPvoiK96PHVFamAmVM,4063
236
236
  python_cad_tools/templates/project/model.py,sha256=B4ux3rwl8bSVl8V9egDRivVP6WutW4d7Hy8lJwMiZyg,4995
237
237
  python_cad_tools/templates/project/pyproject.toml,sha256=c2wqaOdiWTmk2mBnLbMvCFbLFTpBcwLlIB4mdxNyk4I,716
238
- python_cad_tools-0.1.29.dist-info/licenses/LICENSE,sha256=FqSceTmQgl-a1a4JK6fhf1yZdUf-inyBp5qdx4xZ73s,35282
239
- python_cad_tools-0.1.29.dist-info/METADATA,sha256=eAc-AjU7orx-PLgrgIULCNoEzcAIXFPmthdA2DZ4YjA,8883
240
- python_cad_tools-0.1.29.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
241
- python_cad_tools-0.1.29.dist-info/entry_points.txt,sha256=jl-7a_ZJ5dRB0pxsIZx4LUkYZpkj9bGENqfU3VS7Xgo,57
242
- python_cad_tools-0.1.29.dist-info/top_level.txt,sha256=0ER82XyeYmT23LXXidp_s8El0xS4jQOpu7xnHeDwlXo,17
243
- python_cad_tools-0.1.29.dist-info/RECORD,,
238
+ python_cad_tools-0.1.30.dist-info/licenses/LICENSE,sha256=FqSceTmQgl-a1a4JK6fhf1yZdUf-inyBp5qdx4xZ73s,35282
239
+ python_cad_tools-0.1.30.dist-info/METADATA,sha256=PQO_9bofWo5SgMTXjozP3cQZ3lSHYvK424sbk4RZivs,8883
240
+ python_cad_tools-0.1.30.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
241
+ python_cad_tools-0.1.30.dist-info/entry_points.txt,sha256=jl-7a_ZJ5dRB0pxsIZx4LUkYZpkj9bGENqfU3VS7Xgo,57
242
+ python_cad_tools-0.1.30.dist-info/top_level.txt,sha256=0ER82XyeYmT23LXXidp_s8El0xS4jQOpu7xnHeDwlXo,17
243
+ python_cad_tools-0.1.30.dist-info/RECORD,,