printy3d 0.4.0__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.
printy3d/__init__.py ADDED
@@ -0,0 +1,252 @@
1
+ """Official Python client for the Printy3D API (``/v1``).
2
+
3
+ >>> from printy3d import Printy3D
4
+ >>> client = Printy3D() # PRINTY3D_API_KEY, PRINTY3D_API_URL
5
+ >>> job = client.inspect("model.stl") # upload + inspect + wait
6
+ >>> job.analysis.is_watertight
7
+ """
8
+
9
+ from ._client import DEFAULT_BASE_URL, Printy3D, Source
10
+ from ._errors import (
11
+ APIConnectionError,
12
+ APITimeoutError,
13
+ ExportFailedError,
14
+ FileRejectedError,
15
+ IntegrityError,
16
+ JobCancelledError,
17
+ JobError,
18
+ JobFailedError,
19
+ Printy3DError,
20
+ UploadIncompleteError,
21
+ WaitTimeoutError,
22
+ WebhookSignatureError,
23
+ )
24
+ from ._cad_documents import (
25
+ FIELD_VALID_MARGIN_MM,
26
+ GAP_ATTRIBUTE,
27
+ WALL_ATTRIBUTE,
28
+ CadDigest,
29
+ CadDigestPair,
30
+ CadDigestPart,
31
+ CadRegion,
32
+ CadReport,
33
+ CadReportCopy,
34
+ CadReportMeasure,
35
+ CadReportPair,
36
+ CadReportPairEnd,
37
+ CadReportPart,
38
+ CadReportSource,
39
+ CadReportTruncated,
40
+ )
41
+ from ._models import (
42
+ CadCheckResult,
43
+ Analysis,
44
+ ApiKey,
45
+ ApiKeyPage,
46
+ AppliedRepair,
47
+ Artifact,
48
+ ArtifactList,
49
+ Balance,
50
+ Capacity,
51
+ CreditTransaction,
52
+ CreditTransactionPage,
53
+ DownloadedArtifact,
54
+ Evaluation,
55
+ EvaluationList,
56
+ EventPage,
57
+ Export,
58
+ FidelityReport,
59
+ File,
60
+ FilePage,
61
+ FileUpload,
62
+ Finding,
63
+ Format,
64
+ FormatList,
65
+ IssuedApiKey,
66
+ IssuedWebhookEndpoint,
67
+ Job,
68
+ JobEvent,
69
+ JobPage,
70
+ JobQueue,
71
+ JobUsage,
72
+ Model,
73
+ Organization,
74
+ QualityAssessment,
75
+ RecommendationAssessment,
76
+ RepairIssue,
77
+ RepairProfile,
78
+ RepairProfileList,
79
+ RepairResult,
80
+ ResumableFileUpload,
81
+ ResumableUpload,
82
+ TechnologyRow,
83
+ TechnologyTable,
84
+ ToolResult,
85
+ Transfer,
86
+ UploadPart,
87
+ WebhookEndpoint,
88
+ WebhookEvent,
89
+ )
90
+ from ._resources import RESUMABLE_MAX_BYTES, SINGLE_PUT_MAX_BYTES
91
+ from ._types import (
92
+ TERMINAL_JOB_STATUSES,
93
+ AnalyzeToolParams,
94
+ AssemblyIntent,
95
+ CadCheckParams,
96
+ ConvertParams,
97
+ CutParams,
98
+ CuttingPlane,
99
+ ErrorCode,
100
+ EvaluationQuery,
101
+ EvaluationSummary,
102
+ ExportFormat,
103
+ FindingFrame,
104
+ FindingSeverity,
105
+ InputFormat,
106
+ JobStatus,
107
+ LabelParams,
108
+ LatticeParams,
109
+ MeasureParams,
110
+ MedialParams,
111
+ MirrorParams,
112
+ ProfileId,
113
+ Recipe,
114
+ RemoveSmallPartsParams,
115
+ RepairParams,
116
+ Scale,
117
+ Scope,
118
+ Smoothing,
119
+ StructuralComponentsParams,
120
+ StructuralFeaParams,
121
+ StructuralFragilityParams,
122
+ StructuralHeatmapParams,
123
+ StructuralMeasureAllParams,
124
+ StructuralReliefParams,
125
+ Thickness,
126
+ ThicknessToolParams,
127
+ ToolName,
128
+ ToolParams,
129
+ )
130
+ from ._version import __version__
131
+ from ._webhooks import verify_webhook
132
+
133
+ __all__ = [
134
+ "FIELD_VALID_MARGIN_MM",
135
+ "GAP_ATTRIBUTE",
136
+ "WALL_ATTRIBUTE",
137
+ "CadDigest",
138
+ "CadDigestPair",
139
+ "CadDigestPart",
140
+ "CadRegion",
141
+ "CadReport",
142
+ "CadReportCopy",
143
+ "CadReportMeasure",
144
+ "CadReportPair",
145
+ "CadReportPairEnd",
146
+ "CadReportPart",
147
+ "CadReportSource",
148
+ "CadReportTruncated",
149
+ "CadCheckResult",
150
+ "APIConnectionError",
151
+ "APITimeoutError",
152
+ "Analysis",
153
+ "AnalyzeToolParams",
154
+ "ApiKey",
155
+ "ApiKeyPage",
156
+ "AppliedRepair",
157
+ "Artifact",
158
+ "ArtifactList",
159
+ "Balance",
160
+ "Capacity",
161
+ "ConvertParams",
162
+ "CreditTransaction",
163
+ "CreditTransactionPage",
164
+ "CutParams",
165
+ "CuttingPlane",
166
+ "DEFAULT_BASE_URL",
167
+ "DownloadedArtifact",
168
+ "ErrorCode",
169
+ "EventPage",
170
+ "Export",
171
+ "ExportFailedError",
172
+ "ExportFormat",
173
+ "FidelityReport",
174
+ "File",
175
+ "FilePage",
176
+ "FileRejectedError",
177
+ "FileUpload",
178
+ "Format",
179
+ "FormatList",
180
+ "InputFormat",
181
+ "IntegrityError",
182
+ "IssuedApiKey",
183
+ "Job",
184
+ "JobCancelledError",
185
+ "JobError",
186
+ "JobEvent",
187
+ "JobFailedError",
188
+ "JobPage",
189
+ "JobQueue",
190
+ "JobStatus",
191
+ "JobUsage",
192
+ "LabelParams",
193
+ "LatticeParams",
194
+ "MeasureParams",
195
+ "MedialParams",
196
+ "MirrorParams",
197
+ "Model",
198
+ "Organization",
199
+ "Printy3D",
200
+ "Printy3DError",
201
+ "ProfileId",
202
+ "QualityAssessment",
203
+ "Recipe",
204
+ "RecommendationAssessment",
205
+ "RemoveSmallPartsParams",
206
+ "RepairIssue",
207
+ "RepairParams",
208
+ "RepairProfile",
209
+ "RepairProfileList",
210
+ "RepairResult",
211
+ "RESUMABLE_MAX_BYTES",
212
+ "ResumableFileUpload",
213
+ "ResumableUpload",
214
+ "SINGLE_PUT_MAX_BYTES",
215
+ "Scale",
216
+ "Scope",
217
+ "Smoothing",
218
+ "Source",
219
+ "StructuralComponentsParams",
220
+ "StructuralFeaParams",
221
+ "StructuralFragilityParams",
222
+ "StructuralHeatmapParams",
223
+ "StructuralMeasureAllParams",
224
+ "StructuralReliefParams",
225
+ "TERMINAL_JOB_STATUSES",
226
+ "Thickness",
227
+ "ThicknessToolParams",
228
+ "ToolName",
229
+ "ToolParams",
230
+ "ToolResult",
231
+ "Transfer",
232
+ "UploadIncompleteError",
233
+ "UploadPart",
234
+ "WaitTimeoutError",
235
+ "__version__",
236
+ "AssemblyIntent",
237
+ "CadCheckParams",
238
+ "Evaluation",
239
+ "EvaluationList",
240
+ "EvaluationQuery",
241
+ "EvaluationSummary",
242
+ "Finding",
243
+ "FindingFrame",
244
+ "FindingSeverity",
245
+ "IssuedWebhookEndpoint",
246
+ "TechnologyRow",
247
+ "TechnologyTable",
248
+ "WebhookEndpoint",
249
+ "WebhookEvent",
250
+ "WebhookSignatureError",
251
+ "verify_webhook",
252
+ ]
@@ -0,0 +1,230 @@
1
+ """The two files a ``cad_check`` job stores: ``cad_report`` and ``cad_digest`` (schema 1 to 3).
2
+
3
+ A schema 3 file carries every field below. A file of schema 1 or 2 has no ``min_at``, ``min_to``,
4
+ ``wall_to``, ``gap_to``, ``methods``, caps or self-touch fields: those read as ``None``. The
5
+ Rolling Ball fields (``walls_ball``, ``min_wall_ball_mm``, ...) exist only when ``methods`` lists
6
+ ``"ball"``; ``to_dict`` leaves them out when the file had no such key, so a file round-trips as it was.
7
+ All lengths are millimetres. A point inside a part is in the shape's own frame (it applies to
8
+ every placed copy); a point of a pair is in the frame of the whole assembly.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import dataclasses
14
+ from dataclasses import dataclass, field
15
+ from typing import Any, Dict, FrozenSet, List, Mapping, Optional, Type, TypeVar, cast
16
+
17
+ from ._models import Model
18
+
19
+ __all__ = [
20
+ "CadDigest",
21
+ "CadDigestPair",
22
+ "CadDigestPart",
23
+ "CadRegion",
24
+ "CadReport",
25
+ "CadReportCopy",
26
+ "CadReportMeasure",
27
+ "CadReportPair",
28
+ "CadReportPairEnd",
29
+ "CadReportPart",
30
+ "CadReportSource",
31
+ "CadReportTruncated",
32
+ "FIELD_VALID_MARGIN_MM",
33
+ "GAP_ATTRIBUTE",
34
+ "WALL_ATTRIBUTE",
35
+ ]
36
+
37
+ #: Names of the preview GLB's per-vertex thickness attributes.
38
+ WALL_ATTRIBUTE = "_WALL_MM"
39
+ GAP_ATTRIBUTE = "_GAP_MM"
40
+ #: A field value is a reading when it is below its cap by more than this.
41
+ FIELD_VALID_MARGIN_MM = 0.0001
42
+
43
+ D = TypeVar("D", bound="_Document")
44
+ _RESERVED = {"omit_if_none": True}
45
+
46
+
47
+ class _Document(Model):
48
+ """A model that leaves a reserved field out of ``to_dict`` when the file had no such key."""
49
+
50
+ _sent: FrozenSet[str] = frozenset()
51
+
52
+ @classmethod
53
+ def from_dict(cls: Type[D], data: Mapping[str, Any]) -> D:
54
+ obj = super().from_dict(data)
55
+ obj._sent = frozenset(data)
56
+ return obj
57
+
58
+ def to_dict(self) -> Dict[str, Any]:
59
+ out = super().to_dict()
60
+ for f in dataclasses.fields(cast(Any, self)):
61
+ if f.metadata.get("omit_if_none") and f.name not in self._sent:
62
+ if getattr(self, f.name) is None:
63
+ out.pop(f.name, None)
64
+ return out
65
+
66
+
67
+ # --- cad_report ----------------------------------------------------------------------
68
+
69
+
70
+ @dataclass
71
+ class CadReportMeasure(_Document):
72
+ chord_mm: float
73
+ accuracy_mm: float
74
+ wall_cap_mm: float
75
+ gap_cap_mm: float
76
+ sample_limit_per_shape: int
77
+ #: Schema 3: the thickness methods measured, ``["ray"]`` or ``["ray", "ball"]``.
78
+ methods: Optional[List[str]] = None
79
+
80
+
81
+ @dataclass
82
+ class CadReportSource(_Document):
83
+ files: List[str]
84
+ seconds: float
85
+ triangles: int
86
+ solids: int
87
+ #: Placements the checker could not read; ``None`` from a checker that did not count them.
88
+ unsupported_placements: Optional[int] = None
89
+
90
+
91
+ @dataclass
92
+ class CadRegion(_Document):
93
+ """One wall or gap region of a part."""
94
+
95
+ min_mm: float
96
+ median_mm: float
97
+ area_mm2: float
98
+ centroid: List[float]
99
+ bbox_min: List[float]
100
+ bbox_max: List[float]
101
+ #: Schema 3: the sample point of the region's smallest reading, and the point it reached.
102
+ min_at: Optional[List[float]] = None
103
+ min_to: Optional[List[float]] = None
104
+
105
+
106
+ @dataclass
107
+ class CadReportCopy(_Document):
108
+ """One placed copy of a part (schema 2 and 3)."""
109
+
110
+ copy: str # "{part id}#{n}"
111
+ path: List[str]
112
+
113
+
114
+ @dataclass
115
+ class CadReportPart(_Document):
116
+ id: str
117
+ name: str
118
+ paths: List[List[str]]
119
+ quantity: int
120
+ status: str # "closed", "open" or "sheet"
121
+ solids: int
122
+ size_mm: List[float]
123
+ area_mm2: float
124
+ walls: List[CadRegion]
125
+ gaps_inside: List[CadRegion]
126
+ volume_mm3: Optional[float] = None # None unless the part is closed
127
+ copies: Optional[List[CadReportCopy]] = None # schema 2 and 3
128
+ #: Schema 3: mesh edges where two surfaces of the solid meet with no material between them, and the
129
+ #: midpoint of the first one (set exactly when the count is above 0).
130
+ self_touch_edges: Optional[int] = None
131
+ self_touch_at: Optional[List[float]] = None
132
+ #: Rolling Ball regions, present only when the report's ``methods`` lists ``"ball"``.
133
+ walls_ball: Optional[List[CadRegion]] = field(default=None, metadata=_RESERVED)
134
+ gaps_inside_ball: Optional[List[CadRegion]] = field(default=None, metadata=_RESERVED)
135
+
136
+
137
+ @dataclass
138
+ class CadReportPairEnd(_Document):
139
+ part: str
140
+ path: List[str]
141
+ copy: Optional[str] = None # schema 2 and 3
142
+
143
+
144
+ @dataclass
145
+ class CadReportPair(_Document):
146
+ a: CadReportPairEnd
147
+ b: CadReportPairEnd
148
+ same_part: bool
149
+ kind: str # "apart", "touching" or "overlap"
150
+ location: List[float] # in the frame of the whole assembly
151
+ distance_mm: Optional[float] = None
152
+ overlap_depth_mm: Optional[float] = None
153
+
154
+
155
+ @dataclass
156
+ class CadReportTruncated(_Document):
157
+ pairs: bool
158
+ regions: bool
159
+
160
+
161
+ @dataclass
162
+ class CadReport(_Document):
163
+ """``cad_report.json``: every part, wall and gap region, and part pair."""
164
+
165
+ schema_version: int
166
+ units: str
167
+ measure: CadReportMeasure
168
+ source: CadReportSource
169
+ parts: List[CadReportPart]
170
+ pairs: List[CadReportPair]
171
+ truncated: CadReportTruncated
172
+
173
+
174
+ # --- cad_digest ----------------------------------------------------------------------
175
+
176
+
177
+ @dataclass
178
+ class CadDigestPart(_Document):
179
+ id: str
180
+ name: str
181
+ quantity: int
182
+ status: str
183
+ longest_mm: float
184
+ min_wall_mm: Optional[float] = None
185
+ #: From schema 3 the thinnest point and the point its reading reached; each is ``None``
186
+ #: exactly when its minimum is.
187
+ wall_location: Optional[List[float]] = None
188
+ wall_to: Optional[List[float]] = None
189
+ min_gap_inside_mm: Optional[float] = None
190
+ gap_location: Optional[List[float]] = None
191
+ gap_to: Optional[List[float]] = None
192
+ self_touch_edges: Optional[int] = None
193
+ self_touch_location: Optional[List[float]] = None
194
+ #: Rolling Ball readings, present only when the digest's ``methods`` lists ``"ball"``.
195
+ min_wall_ball_mm: Optional[float] = field(default=None, metadata=_RESERVED)
196
+ wall_ball_location: Optional[List[float]] = field(default=None, metadata=_RESERVED)
197
+ wall_ball_to: Optional[List[float]] = field(default=None, metadata=_RESERVED)
198
+ min_gap_inside_ball_mm: Optional[float] = field(default=None, metadata=_RESERVED)
199
+ gap_ball_location: Optional[List[float]] = field(default=None, metadata=_RESERVED)
200
+ gap_ball_to: Optional[List[float]] = field(default=None, metadata=_RESERVED)
201
+
202
+
203
+ @dataclass
204
+ class CadDigestPair(_Document):
205
+ a_name: str
206
+ b_name: str
207
+ same_part: bool
208
+ kind: str
209
+ location: List[float]
210
+ a_copy: Optional[str] = None # schema 2 and 3
211
+ b_copy: Optional[str] = None
212
+ distance_mm: Optional[float] = None
213
+
214
+
215
+ @dataclass
216
+ class CadDigest(_Document):
217
+ """``cad_digest.json``: the small part of a check the evaluation reads."""
218
+
219
+ schema_version: int
220
+ accuracy_mm: float
221
+ sample_limit_per_shape: int
222
+ truncated: bool
223
+ parts: List[CadDigestPart]
224
+ pairs: List[CadDigestPair]
225
+ #: Schema 3: the caps the readings were measured under (a reading equal to its cap is
226
+ #: "no reading") and the methods measured.
227
+ wall_cap_mm: Optional[float] = None
228
+ gap_cap_mm: Optional[float] = None
229
+ methods: Optional[List[str]] = None
230
+ unsupported_placements: Optional[int] = None