python-cad-tools 0.1.26__py3-none-any.whl → 0.1.27__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.
@@ -40,6 +40,7 @@ from .renders import (
40
40
  _DEPTH_SCALE,
41
41
  _LINEAR_DEFLECTION,
42
42
  _rasterize,
43
+ display_color,
43
44
  encode_png,
44
45
  )
45
46
 
@@ -153,7 +154,7 @@ def included_scene(model, view: CapturedView) -> tuple[np.ndarray, np.ndarray, n
153
154
  vertices = np.asarray(points, dtype=np.float64)
154
155
  all_vertices.append(vertices)
155
156
  all_faces.append(np.asarray(triangles, dtype=np.int64) + offset)
156
- color = np.asarray(element.color_rgb or _DEFAULT_COLOR, dtype=np.float64)
157
+ color = np.asarray(display_color(element), dtype=np.float64)
157
158
  all_colors.append(np.repeat(color[None, :], len(triangles), axis=0))
158
159
  all_owners.append(np.full(len(triangles), number, dtype=np.int64))
159
160
  used.append(element)
@@ -13,6 +13,7 @@ from ..determinism import write_json
13
13
  from ..exceptions import BuildExportError
14
14
  from ..geometry import combined_bounds, tessellate
15
15
  from .base import selected_elements
16
+ from .renders import display_color
16
17
 
17
18
 
18
19
  class GlbExporter:
@@ -35,7 +36,7 @@ class GlbExporter:
35
36
  material = trimesh.visual.material.PBRMaterial(
36
37
  name=element.material.name if element.material else element.id,
37
38
  baseColorFactor=[
38
- int(round(channel * 255)) for channel in (element.color_rgb or (0.7, 0.7, 0.7))
39
+ int(round(channel * 255)) for channel in display_color(element)
39
40
  ]
40
41
  + [255],
41
42
  metallicFactor=0.0,
@@ -19,6 +19,7 @@ import struct
19
19
  import zlib
20
20
  from dataclasses import dataclass
21
21
  from pathlib import Path
22
+ from typing import TYPE_CHECKING
22
23
 
23
24
  import numpy as np
24
25
 
@@ -26,6 +27,9 @@ from ..exceptions import ArtifactIntegrityError, BuildExportError
26
27
  from ..geometry import tessellate
27
28
  from .base import selected_elements
28
29
 
30
+ if TYPE_CHECKING:
31
+ from ..elements import Color, DesignElement
32
+
29
33
  #: The views, in output order, and the file each writes (``<stem>_<view>.png``).
30
34
  RENDER_VIEWS: tuple[str, ...] = ("top", "front", "side", "three_quarter")
31
35
  #: Longest image edge in pixels; the other edge follows the view's proportions.
@@ -70,6 +74,18 @@ class _View:
70
74
  toward: tuple[float, float, float]
71
75
 
72
76
 
77
+ def display_color(element: DesignElement) -> Color:
78
+ """The colour an element is drawn in: its own, else its material's, else the default grey.
79
+
80
+ 2026-11-05: an element coloured only through its ``MaterialSpec`` showed grey in the viewer
81
+ (the IFC export already fell back to the material colour)."""
82
+ if element.color_rgb is not None:
83
+ return element.color_rgb
84
+ if element.material is not None and element.material.color_rgb is not None:
85
+ return element.material.color_rgb
86
+ return _DEFAULT_COLOR
87
+
88
+
73
89
  def _unit(vector: tuple[float, float, float]) -> tuple[float, float, float]:
74
90
  x, y, z = vector
75
91
  length = math.sqrt(x * x + y * y + z * z)
@@ -137,7 +153,7 @@ def _scene(model) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
137
153
  continue
138
154
  vertices = np.asarray(points, dtype=np.float64)
139
155
  faces = np.asarray(triangles, dtype=np.int64) + offset
140
- color = np.asarray(element.color_rgb or _DEFAULT_COLOR, dtype=np.float64)
156
+ color = np.asarray(display_color(element), dtype=np.float64)
141
157
  all_vertices.append(vertices)
142
158
  all_faces.append(faces)
143
159
  all_colors.append(np.repeat(color[None, :], len(faces), axis=0))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-cad-tools
3
- Version: 0.1.26
3
+ Version: 0.1.27
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
@@ -203,11 +203,11 @@ python_cad_tools/drawings/_catalog.py,sha256=8szKj-RU5-E2BV5NadgpJ75zq06VPYjmAuW
203
203
  python_cad_tools/drawings/_validation.py,sha256=0XjSdZ580HmWnPHb0m6zgGT90TdsO5xhjm0XbDQIh8w,12924
204
204
  python_cad_tools/exporters/__init__.py,sha256=HJ88im5HmFBz4LWN4oj-QSgwk3F_kg1uI7FVXx55h6U,278
205
205
  python_cad_tools/exporters/base.py,sha256=4vbDSv97V3BjXLCbKIN0m78w2SXM_ZUhrFgnLMbAjJ4,453
206
- python_cad_tools/exporters/custom_view.py,sha256=2BM6TXoQ4vPvCwCsUkbfCANux30PFxXqdXWVdlJ0nI8,26608
207
- python_cad_tools/exporters/glb.py,sha256=V1TbEKmPZFdDbYRewOKmWjByjHTtApr1ARvJ-bG-sw0,4429
206
+ python_cad_tools/exporters/custom_view.py,sha256=KD_4In_YR1brmjhuTq7A0V5wy4lMesJPztGb-So2cvc,26614
207
+ python_cad_tools/exporters/glb.py,sha256=FK7-CDA7O-TOCy79iQpr23-T6Fua4Oy5zl9CPbijtPo,4448
208
208
  python_cad_tools/exporters/ifc.py,sha256=M6iimIMwWV7txuog2-83UIoWfiCica4b9optNlZDRdo,32012
209
209
  python_cad_tools/exporters/quantities.py,sha256=mCYOl1vvK0FJqI_Nsc4352afAwRSqm2hi7Dv7Rsbe74,5654
210
- python_cad_tools/exporters/renders.py,sha256=PHjkqCdENKe5P-nk1EJUQMRGtmVWFdt6AzCtI_Fnk6g,20633
210
+ python_cad_tools/exporters/renders.py,sha256=qh-tcBlmHdcXT-6KynfZqZ25p80Ixi6ZavXOSRawDXs,21251
211
211
  python_cad_tools/exporters/step.py,sha256=-rLpPfbfv2Ql-LGZp1nH4Y1UUgDiomF0eukxvmZVDLY,7038
212
212
  python_cad_tools/exporters/drawings/__init__.py,sha256=fVYW-6UJy-Ts2XSTG_ajjyuTblpmFBy5H-j-XRWhXM8,136
213
213
  python_cad_tools/exporters/drawings/annotations.py,sha256=l1HjTFK33J7j_UCEivaZUKV44xPxhyKsOAlrN-JRftg,18627
@@ -233,9 +233,9 @@ python_cad_tools/templates/project/config.py,sha256=nhzK6fQJkzlA7qr6gU4NgC92QghW
233
233
  python_cad_tools/templates/project/drawing_annotations.py,sha256=6OY7qQUGtCV2sl-hjBKHABKvgcPvoiK96PHVFamAmVM,4063
234
234
  python_cad_tools/templates/project/model.py,sha256=B4ux3rwl8bSVl8V9egDRivVP6WutW4d7Hy8lJwMiZyg,4995
235
235
  python_cad_tools/templates/project/pyproject.toml,sha256=c2wqaOdiWTmk2mBnLbMvCFbLFTpBcwLlIB4mdxNyk4I,716
236
- python_cad_tools-0.1.26.dist-info/licenses/LICENSE,sha256=FqSceTmQgl-a1a4JK6fhf1yZdUf-inyBp5qdx4xZ73s,35282
237
- python_cad_tools-0.1.26.dist-info/METADATA,sha256=HsGN4UqWABYh_Guft0pSgpcQkUQXQTtjCt71h4CtBNI,8883
238
- python_cad_tools-0.1.26.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
239
- python_cad_tools-0.1.26.dist-info/entry_points.txt,sha256=jl-7a_ZJ5dRB0pxsIZx4LUkYZpkj9bGENqfU3VS7Xgo,57
240
- python_cad_tools-0.1.26.dist-info/top_level.txt,sha256=0ER82XyeYmT23LXXidp_s8El0xS4jQOpu7xnHeDwlXo,17
241
- python_cad_tools-0.1.26.dist-info/RECORD,,
236
+ python_cad_tools-0.1.27.dist-info/licenses/LICENSE,sha256=FqSceTmQgl-a1a4JK6fhf1yZdUf-inyBp5qdx4xZ73s,35282
237
+ python_cad_tools-0.1.27.dist-info/METADATA,sha256=VAYf5J_vMOX5_SrsH9cZBNeTIhRUEOiOnlmmtq9OLeQ,8883
238
+ python_cad_tools-0.1.27.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
239
+ python_cad_tools-0.1.27.dist-info/entry_points.txt,sha256=jl-7a_ZJ5dRB0pxsIZx4LUkYZpkj9bGENqfU3VS7Xgo,57
240
+ python_cad_tools-0.1.27.dist-info/top_level.txt,sha256=0ER82XyeYmT23LXXidp_s8El0xS4jQOpu7xnHeDwlXo,17
241
+ python_cad_tools-0.1.27.dist-info/RECORD,,