solidworks-mcp-python 1.5.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.
- solidworks_mcp/__init__.py +57 -0
- solidworks_mcp/adapters/__init__.py +40 -0
- solidworks_mcp/adapters/base.py +1882 -0
- solidworks_mcp/adapters/circuit_breaker.py +2052 -0
- solidworks_mcp/adapters/com_executor.py +252 -0
- solidworks_mcp/adapters/complexity_analyzer.py +272 -0
- solidworks_mcp/adapters/connection_pool.py +1884 -0
- solidworks_mcp/adapters/factory.py +366 -0
- solidworks_mcp/adapters/intelligent_router.py +218 -0
- solidworks_mcp/adapters/mock_adapter.py +4016 -0
- solidworks_mcp/adapters/pywin32_adapter.py +2842 -0
- solidworks_mcp/adapters/solidworks/__init__.py +17 -0
- solidworks_mcp/adapters/solidworks/bitmap.py +180 -0
- solidworks_mcp/adapters/solidworks/com_utils.py +56 -0
- solidworks_mcp/adapters/solidworks/dimension_layout.py +753 -0
- solidworks_mcp/adapters/solidworks/documentation.py +1476 -0
- solidworks_mcp/adapters/solidworks/drawing_standard.py +1993 -0
- solidworks_mcp/adapters/solidworks/face_selection.py +392 -0
- solidworks_mcp/adapters/solidworks/features.py +3362 -0
- solidworks_mcp/adapters/solidworks/io.py +3649 -0
- solidworks_mcp/adapters/solidworks/rebuild_diagnostics.py +269 -0
- solidworks_mcp/adapters/solidworks/rebuild_inspector.py +146 -0
- solidworks_mcp/adapters/solidworks/selection.py +308 -0
- solidworks_mcp/adapters/solidworks/sketch.py +2545 -0
- solidworks_mcp/adapters/sw_feature_errors.py +66 -0
- solidworks_mcp/adapters/sw_type_info.py +317 -0
- solidworks_mcp/adapters/vba_adapter.py +318 -0
- solidworks_mcp/adapters/vba_macro_executor.py +215 -0
- solidworks_mcp/agents/__init__.py +68 -0
- solidworks_mcp/agents/design_knowledge/assembly_patterns.md +127 -0
- solidworks_mcp/agents/design_knowledge/hinges.md +118 -0
- solidworks_mcp/agents/design_knowledge/snap_fits.md +93 -0
- solidworks_mcp/agents/design_knowledge/solidworks_basics.md +3 -0
- solidworks_mcp/agents/design_knowledge/tolerancing.md +128 -0
- solidworks_mcp/agents/harness.py +216 -0
- solidworks_mcp/agents/history_db.py +1508 -0
- solidworks_mcp/agents/retrieval_index.py +164 -0
- solidworks_mcp/agents/schemas.py +165 -0
- solidworks_mcp/agents/smoke_test.py +285 -0
- solidworks_mcp/agents/soc_exporter.py +650 -0
- solidworks_mcp/agents/soc_pickup.py +332 -0
- solidworks_mcp/agents/soc_rewind.py +221 -0
- solidworks_mcp/agents/vector_rag.py +665 -0
- solidworks_mcp/cache/__init__.py +5 -0
- solidworks_mcp/cache/response_cache.py +164 -0
- solidworks_mcp/config.py +729 -0
- solidworks_mcp/exceptions.py +37 -0
- solidworks_mcp/security/__init__.py +68 -0
- solidworks_mcp/security/auth.py +128 -0
- solidworks_mcp/security/cors.py +27 -0
- solidworks_mcp/security/rate_limiting.py +90 -0
- solidworks_mcp/security/runtime.py +155 -0
- solidworks_mcp/server.py +777 -0
- solidworks_mcp/server_cli_fixed.py +120 -0
- solidworks_mcp/setup/__init__.py +1 -0
- solidworks_mcp/setup/cli.py +399 -0
- solidworks_mcp/setup/clients.py +157 -0
- solidworks_mcp/setup/config_file.py +230 -0
- solidworks_mcp/setup/handshake.py +202 -0
- solidworks_mcp/setup/launcher.py +102 -0
- solidworks_mcp/setup/legacy.py +100 -0
- solidworks_mcp/setup/registration.py +193 -0
- solidworks_mcp/setup/solidworks.py +49 -0
- solidworks_mcp/tools/__init__.py +64 -0
- solidworks_mcp/tools/analysis.py +723 -0
- solidworks_mcp/tools/automation.py +578 -0
- solidworks_mcp/tools/docs_discovery.py +1476 -0
- solidworks_mcp/tools/drawing.py +1015 -0
- solidworks_mcp/tools/drawing_analysis.py +456 -0
- solidworks_mcp/tools/drawing_automation.py +627 -0
- solidworks_mcp/tools/engineering_data.py +466 -0
- solidworks_mcp/tools/error_classifier.py +232 -0
- solidworks_mcp/tools/export.py +833 -0
- solidworks_mcp/tools/file_facts.py +40 -0
- solidworks_mcp/tools/file_management.py +1473 -0
- solidworks_mcp/tools/input_compat.py +17 -0
- solidworks_mcp/tools/macro_recording.py +464 -0
- solidworks_mcp/tools/modeling.py +2360 -0
- solidworks_mcp/tools/sketching.py +1422 -0
- solidworks_mcp/tools/template_management.py +367 -0
- solidworks_mcp/tools/tool_boundary.py +280 -0
- solidworks_mcp/tools/vba_generation.py +1145 -0
- solidworks_mcp/ui/__init__.py +9 -0
- solidworks_mcp/ui/local_llm.py +725 -0
- solidworks_mcp/ui/routers/__init__.py +10 -0
- solidworks_mcp/ui/routers/checkpoint.py +24 -0
- solidworks_mcp/ui/routers/docs.py +47 -0
- solidworks_mcp/ui/routers/llm.py +83 -0
- solidworks_mcp/ui/routers/local_model.py +69 -0
- solidworks_mcp/ui/routers/model.py +75 -0
- solidworks_mcp/ui/routers/preview.py +38 -0
- solidworks_mcp/ui/routers/session.py +161 -0
- solidworks_mcp/ui/routers/viewer.py +154 -0
- solidworks_mcp/ui/schemas.py +502 -0
- solidworks_mcp/ui/server.py +298 -0
- solidworks_mcp/ui/service.py +481 -0
- solidworks_mcp/ui/services/__init__.py +136 -0
- solidworks_mcp/ui/services/_utils.py +958 -0
- solidworks_mcp/ui/services/checkpoint_service.py +1110 -0
- solidworks_mcp/ui/services/docs_service.py +282 -0
- solidworks_mcp/ui/services/llm_service.py +956 -0
- solidworks_mcp/ui/services/model_service.py +459 -0
- solidworks_mcp/ui/services/parameter_repair_service.py +314 -0
- solidworks_mcp/ui/services/preview_service.py +489 -0
- solidworks_mcp/ui/services/session_service.py +1389 -0
- solidworks_mcp/utils/__init__.py +9 -0
- solidworks_mcp/utils/feature_tree_classifier.py +342 -0
- solidworks_mcp/utils/logging.py +76 -0
- solidworks_mcp/utils/validation.py +77 -0
- solidworks_mcp/version.py +8 -0
- solidworks_mcp_python-1.5.0.dist-info/METADATA +410 -0
- solidworks_mcp_python-1.5.0.dist-info/RECORD +115 -0
- solidworks_mcp_python-1.5.0.dist-info/WHEEL +4 -0
- solidworks_mcp_python-1.5.0.dist-info/entry_points.txt +3 -0
- solidworks_mcp_python-1.5.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"""VBA macro execution lifecycle management for SolidWorks automation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import tempfile
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from .base import AdapterResult, AdapterResultStatus
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True)
|
|
15
|
+
class MacroExecutionRequest:
|
|
16
|
+
"""Request to execute a VBA macro.
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
macro_code (str): The macro code value.
|
|
20
|
+
macro_name (str): The macro name value.
|
|
21
|
+
subroutine (str): The subroutine value.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
macro_code: str
|
|
25
|
+
macro_name: str
|
|
26
|
+
subroutine: str = "Main"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass(frozen=True)
|
|
30
|
+
class MacroExecutionResult:
|
|
31
|
+
"""Result of VBA macro execution.
|
|
32
|
+
|
|
33
|
+
Attributes:
|
|
34
|
+
duration_seconds (float): The duration seconds value.
|
|
35
|
+
error (str | None): The error value.
|
|
36
|
+
macro_name (str): The macro name value.
|
|
37
|
+
output (str | dict[str, Any] | None): The output value.
|
|
38
|
+
success (bool): The success value.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
success: bool
|
|
42
|
+
macro_name: str
|
|
43
|
+
output: str | dict[str, Any] | None = None
|
|
44
|
+
error: str | None = None
|
|
45
|
+
duration_seconds: float = 0.0
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class VbaMacroExecutor:
|
|
49
|
+
"""Manage VBA macro execution with save and tracking.
|
|
50
|
+
|
|
51
|
+
This executor handles the full lifecycle: code generation, on-disk persistence,
|
|
52
|
+
execution via the backing adapter, and result tracking.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
temp_macro_dir (Path | None): The temp macro dir value. Defaults to None.
|
|
56
|
+
|
|
57
|
+
Attributes:
|
|
58
|
+
_temp_macro_dir (Any): The temp macro dir value.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
def __init__(self, temp_macro_dir: Path | None = None) -> None:
|
|
62
|
+
"""Initialize macro executor.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
temp_macro_dir (Path | None): The temp macro dir value. Defaults to None.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
None: None.
|
|
69
|
+
"""
|
|
70
|
+
self._temp_macro_dir = temp_macro_dir or Path(tempfile.gettempdir())
|
|
71
|
+
self._execution_history: dict[str, MacroExecutionResult] = {}
|
|
72
|
+
|
|
73
|
+
async def execute_macro(
|
|
74
|
+
self,
|
|
75
|
+
request: MacroExecutionRequest,
|
|
76
|
+
backing_adapter: Any,
|
|
77
|
+
) -> AdapterResult[MacroExecutionResult]:
|
|
78
|
+
"""Provide execute macro support for the vba macro executor.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
request (MacroExecutionRequest): The request value.
|
|
82
|
+
backing_adapter (Any): The backing adapter value.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
AdapterResult[MacroExecutionResult]: The result produced by the operation.
|
|
86
|
+
"""
|
|
87
|
+
start_time = datetime.utcnow()
|
|
88
|
+
macro_path = self._save_macro_to_disk(request.macro_code, request.macro_name)
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
result = await self._execute_via_adapter(
|
|
92
|
+
macro_path=macro_path,
|
|
93
|
+
subroutine=request.subroutine,
|
|
94
|
+
backing_adapter=backing_adapter,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
duration = (datetime.utcnow() - start_time).total_seconds()
|
|
98
|
+
execution_result = MacroExecutionResult(
|
|
99
|
+
success=result.get("success", False),
|
|
100
|
+
macro_name=request.macro_name,
|
|
101
|
+
output=result.get("output"),
|
|
102
|
+
error=result.get("error"),
|
|
103
|
+
duration_seconds=duration,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
self._execution_history[request.macro_name] = execution_result
|
|
107
|
+
|
|
108
|
+
return AdapterResult(
|
|
109
|
+
status=AdapterResultStatus.SUCCESS,
|
|
110
|
+
data=execution_result,
|
|
111
|
+
metadata={
|
|
112
|
+
"macro_path": str(macro_path),
|
|
113
|
+
"macro_name": request.macro_name,
|
|
114
|
+
"duration_seconds": duration,
|
|
115
|
+
"subroutine": request.subroutine,
|
|
116
|
+
},
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
except Exception as exc:
|
|
120
|
+
duration = (datetime.utcnow() - start_time).total_seconds()
|
|
121
|
+
execution_result = MacroExecutionResult(
|
|
122
|
+
success=False,
|
|
123
|
+
macro_name=request.macro_name,
|
|
124
|
+
error=str(exc),
|
|
125
|
+
duration_seconds=duration,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
self._execution_history[request.macro_name] = execution_result
|
|
129
|
+
|
|
130
|
+
return AdapterResult(
|
|
131
|
+
status=AdapterResultStatus.ERROR,
|
|
132
|
+
error=f"macro execution failed: {exc}",
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
def get_execution_history(
|
|
136
|
+
self, macro_name: str | None = None
|
|
137
|
+
) -> dict[
|
|
138
|
+
str,
|
|
139
|
+
MacroExecutionResult,
|
|
140
|
+
]:
|
|
141
|
+
"""Retrieve macro execution history.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
macro_name (str | None): The macro name value. Defaults to None.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
dict[
|
|
148
|
+
str,
|
|
149
|
+
MacroExecutionResult,
|
|
150
|
+
]: A dictionary containing the
|
|
151
|
+
resulting values.
|
|
152
|
+
"""
|
|
153
|
+
if macro_name is not None:
|
|
154
|
+
return (
|
|
155
|
+
{
|
|
156
|
+
macro_name: self._execution_history[macro_name],
|
|
157
|
+
}
|
|
158
|
+
if macro_name in self._execution_history
|
|
159
|
+
else {}
|
|
160
|
+
)
|
|
161
|
+
return dict(self._execution_history)
|
|
162
|
+
|
|
163
|
+
def _save_macro_to_disk(self, macro_code: str, macro_name: str) -> Path:
|
|
164
|
+
"""Save VBA macro code to a file.
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
macro_code (str): The macro code value.
|
|
168
|
+
macro_name (str): The macro name value.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
Path: The result produced by the operation.
|
|
172
|
+
"""
|
|
173
|
+
safe_name = "".join(
|
|
174
|
+
c if c.isalnum() or c in ("_", "-") else "_" for c in macro_name
|
|
175
|
+
)
|
|
176
|
+
timestamp = datetime.utcnow().timestamp()
|
|
177
|
+
macro_file = self._temp_macro_dir / f"{safe_name}_{timestamp}.swp"
|
|
178
|
+
macro_file.write_text(macro_code, encoding="utf-8")
|
|
179
|
+
return macro_file
|
|
180
|
+
|
|
181
|
+
async def _execute_via_adapter(
|
|
182
|
+
self,
|
|
183
|
+
macro_path: Path,
|
|
184
|
+
subroutine: str,
|
|
185
|
+
backing_adapter: Any,
|
|
186
|
+
) -> dict[str, Any]:
|
|
187
|
+
"""Delegate macro execution to backing adapter.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
macro_path (Path): The macro path value.
|
|
191
|
+
subroutine (str): The subroutine value.
|
|
192
|
+
backing_adapter (Any): The backing adapter value.
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
dict[str, Any]: A dictionary containing the resulting values.
|
|
196
|
+
"""
|
|
197
|
+
if not hasattr(backing_adapter, "execute_macro"):
|
|
198
|
+
return {
|
|
199
|
+
"success": False,
|
|
200
|
+
"error": "backing adapter does not support macro execution",
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
try:
|
|
204
|
+
result = await backing_adapter.execute_macro(
|
|
205
|
+
macro_path=str(macro_path),
|
|
206
|
+
subroutine=subroutine,
|
|
207
|
+
)
|
|
208
|
+
if hasattr(result, "data"):
|
|
209
|
+
return result.data or {}
|
|
210
|
+
return result if isinstance(result, dict) else {"output": str(result)}
|
|
211
|
+
except AttributeError:
|
|
212
|
+
return {
|
|
213
|
+
"success": False,
|
|
214
|
+
"error": "adapter execute_macro failed",
|
|
215
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""Agent-testing utilities for SolidWorks MCP custom agents."""
|
|
2
|
+
|
|
3
|
+
from .harness import pretty_json, run_validated_prompt
|
|
4
|
+
from .history_db import (
|
|
5
|
+
DEFAULT_DB_PATH,
|
|
6
|
+
ErrorRecord,
|
|
7
|
+
create_soc_checkpoint,
|
|
8
|
+
find_conversation_events,
|
|
9
|
+
find_recent_errors,
|
|
10
|
+
find_run_timeline,
|
|
11
|
+
get_design_session,
|
|
12
|
+
get_soc_checkpoint,
|
|
13
|
+
init_db,
|
|
14
|
+
insert_conversation_event,
|
|
15
|
+
insert_evidence_link,
|
|
16
|
+
insert_model_state_snapshot,
|
|
17
|
+
insert_plan_checkpoint,
|
|
18
|
+
insert_sketch_graph_snapshot,
|
|
19
|
+
insert_tool_call_record,
|
|
20
|
+
list_evidence_links,
|
|
21
|
+
list_model_state_snapshots,
|
|
22
|
+
list_plan_checkpoints,
|
|
23
|
+
list_sketch_graph_snapshots,
|
|
24
|
+
list_soc_checkpoints,
|
|
25
|
+
list_tool_call_records,
|
|
26
|
+
update_plan_checkpoint,
|
|
27
|
+
upsert_design_session,
|
|
28
|
+
)
|
|
29
|
+
from .retrieval_index import build_local_retrieval_index
|
|
30
|
+
from .schemas import (
|
|
31
|
+
DocsPlan,
|
|
32
|
+
ManufacturabilityReview,
|
|
33
|
+
RecoverableFailure,
|
|
34
|
+
ToolRoutingDecision,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
"DEFAULT_DB_PATH",
|
|
39
|
+
"DocsPlan",
|
|
40
|
+
"ErrorRecord",
|
|
41
|
+
"ManufacturabilityReview",
|
|
42
|
+
"RecoverableFailure",
|
|
43
|
+
"ToolRoutingDecision",
|
|
44
|
+
"build_local_retrieval_index",
|
|
45
|
+
"create_soc_checkpoint",
|
|
46
|
+
"find_conversation_events",
|
|
47
|
+
"get_design_session",
|
|
48
|
+
"get_soc_checkpoint",
|
|
49
|
+
"find_recent_errors",
|
|
50
|
+
"find_run_timeline",
|
|
51
|
+
"init_db",
|
|
52
|
+
"insert_evidence_link",
|
|
53
|
+
"insert_model_state_snapshot",
|
|
54
|
+
"insert_plan_checkpoint",
|
|
55
|
+
"insert_sketch_graph_snapshot",
|
|
56
|
+
"insert_tool_call_record",
|
|
57
|
+
"insert_conversation_event",
|
|
58
|
+
"list_evidence_links",
|
|
59
|
+
"list_model_state_snapshots",
|
|
60
|
+
"list_plan_checkpoints",
|
|
61
|
+
"list_sketch_graph_snapshots",
|
|
62
|
+
"list_soc_checkpoints",
|
|
63
|
+
"list_tool_call_records",
|
|
64
|
+
"pretty_json",
|
|
65
|
+
"run_validated_prompt",
|
|
66
|
+
"update_plan_checkpoint",
|
|
67
|
+
"upsert_design_session",
|
|
68
|
+
]
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# FDM Print-in-Place and Assembly Design Patterns
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This guide covers design patterns for functional 3D-printed assemblies with a focus on
|
|
6
|
+
reducing or eliminating post-print hardware.
|
|
7
|
+
|
|
8
|
+
## Interlocking Joints
|
|
9
|
+
|
|
10
|
+
### Dovetail Joint
|
|
11
|
+
- Classic woodworking joint adapted for FDM
|
|
12
|
+
- Angle: 14–18° is typical (wider = stronger pull resistance, harder to assemble)
|
|
13
|
+
- Clearance: 0.25–0.35 mm per side for PETG
|
|
14
|
+
- Print the male (tail) piece upright; female (pin) piece can be flat
|
|
15
|
+
- Add 0.5 mm chamfer at entry to guide assembly
|
|
16
|
+
|
|
17
|
+
### Mortise and Tenon
|
|
18
|
+
- Simple rectangular tab and slot
|
|
19
|
+
- Clearance: 0.20–0.30 mm per side
|
|
20
|
+
- Tenon width should be 1/3 of joint width for best strength ratio
|
|
21
|
+
- Add 1:5 taper on tenon faces for self-aligning entry
|
|
22
|
+
|
|
23
|
+
### T-Slot / Extrusion Runner
|
|
24
|
+
- Allows sliding and locking at any position
|
|
25
|
+
- T-slot clearance: 0.30–0.45 mm (accounting for layer stepping on angled face)
|
|
26
|
+
- Lock mechanism: quarter-turn cam, set screw boss, or wedge
|
|
27
|
+
|
|
28
|
+
## Multi-Material Print-in-Place
|
|
29
|
+
|
|
30
|
+
### Rigid + Flexible Combination
|
|
31
|
+
- Print rigid structural frame in PLA/PETG
|
|
32
|
+
- Print flexible gasket or grip in TPU (dual-extrusion or manual switch)
|
|
33
|
+
- TPU-to-PLA interface: 0.0 mm clearance (TPU compresses to seal)
|
|
34
|
+
- TPU-to-PETG: same, or -0.05 mm undersizing on TPU for preload seal
|
|
35
|
+
|
|
36
|
+
### Dissolvable Support for Embedded Components
|
|
37
|
+
- Use PVA (water soluble) or BVOH as support for internal channels and print-in-place joints
|
|
38
|
+
- Soak in warm water 2–6 hours post-print
|
|
39
|
+
|
|
40
|
+
## Living Assemblies (Mechanisms in One Print)
|
|
41
|
+
|
|
42
|
+
### Universal Joint (Printed in One Piece)
|
|
43
|
+
- Two yokes + crosspiece, assembled in-print
|
|
44
|
+
- Crosspiece clearance: 0.4–0.5 mm (PETG)
|
|
45
|
+
- Yoke knuckle clearance: 0.3–0.4 mm
|
|
46
|
+
- Print axis: crosspiece horizontal for best print quality
|
|
47
|
+
|
|
48
|
+
### Gear Train (In-Place)
|
|
49
|
+
- Module 1.5–2.0 recommended (coarser = more robust)
|
|
50
|
+
- Clearance on gear flanks (backlash): 0.15–0.25 mm total
|
|
51
|
+
- Print gears with 5–6 top/bottom layers and 4+ perimeters for tooth strength
|
|
52
|
+
- Infill 40–60% for gears under moderate load
|
|
53
|
+
|
|
54
|
+
### Flexible Linkage / Compliant Mechanism
|
|
55
|
+
- Use topology-optimization-inspired curved beams
|
|
56
|
+
- Minimum wall for reliable flex: 0.8 mm (PETG/Nylon), 0.6 mm (TPU)
|
|
57
|
+
- Print in a single orientation — never reorient mid-print
|
|
58
|
+
|
|
59
|
+
## Structural Patterns for FDM
|
|
60
|
+
|
|
61
|
+
### Ribs and Gussets
|
|
62
|
+
- Rib thickness: 60–70% of wall thickness to reduce sink marks
|
|
63
|
+
- Rib height-to-thickness: max 3:1 without risk of print instability
|
|
64
|
+
- Gusset angle: 45° for equal XY and Z load distribution
|
|
65
|
+
|
|
66
|
+
### Honeycomb Infill for Panels
|
|
67
|
+
- For large flat panels, print 20–30% gyroid or honeycomb infill
|
|
68
|
+
- Use 3–4 perimeters for lateral stiffness
|
|
69
|
+
- Add filet radius at panel border (improves layer adhesion under peel loads)
|
|
70
|
+
|
|
71
|
+
### Column / Pillar Features
|
|
72
|
+
- Hollow columns with 2–3 perimeter walls and spiral vase-mode walls are light and stiff
|
|
73
|
+
- Minimum column OD: 6 mm for 0.4 mm nozzle with 2 walls
|
|
74
|
+
- Internal strengthening ribs at 3–6 mm pitch for taller columns
|
|
75
|
+
|
|
76
|
+
## Fastener Boss Design
|
|
77
|
+
|
|
78
|
+
### Heat-Set Insert Boss
|
|
79
|
+
```
|
|
80
|
+
Boss OD = insert OD × 2.0 (minimum 1.5× for space-constrained parts)
|
|
81
|
+
Boss depth = insert length + 0.5 mm clearance at bottom
|
|
82
|
+
Boss ID = (see tolerancing guide table)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Self-Tapping Screw Boss
|
|
86
|
+
```
|
|
87
|
+
Boss OD = screw OD × 2.5
|
|
88
|
+
Pilot hole = screw OD × 0.75 (e.g., M3: drill at 2.25 mm)
|
|
89
|
+
Boss depth = screw length - 1.5 mm
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Through-Hole with Counter-bore
|
|
93
|
+
```
|
|
94
|
+
Through hole = bolt OD + 0.4 mm (M3: 3.4 mm)
|
|
95
|
+
Counter-bore = washer OD + 0.5 mm (M3 washer: 7.0 mm → 7.5 mm bore)
|
|
96
|
+
Counter-bore depth = washer thickness + 0.5 mm
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Print Orientation Rules for Mechanical Parts
|
|
100
|
+
|
|
101
|
+
| Feature | Best Orientation |
|
|
102
|
+
|-----------------------|--------------------------------------------|
|
|
103
|
+
| Snap fit arm | Arm bends parallel to layers (horizontal) |
|
|
104
|
+
| Living hinge | Web horizontal (flat to bed) |
|
|
105
|
+
| Gear teeth | Teeth grow vertically (parallel to Z) |
|
|
106
|
+
| Threaded hole (tapped)| Thread axis vertical |
|
|
107
|
+
| Tensile member | Load axis parallel to X or Y (not Z) |
|
|
108
|
+
| Bearing surface | Bore axis horizontal for rounder hole |
|
|
109
|
+
|
|
110
|
+
## Support-Free Design Tips
|
|
111
|
+
|
|
112
|
+
1. Keep overhangs ≤ 45° from horizontal (or use chamfers instead of undercuts)
|
|
113
|
+
2. Use internal chamfers (45°) instead of horizontal shelves
|
|
114
|
+
3. Replace bridge > 50 mm with an arch or intermediate support pillar
|
|
115
|
+
4. Tilt parts 5–15° to eliminate a single flat overhang without adding supports
|
|
116
|
+
5. Use "teardrop" holes (circle + triangle point at top) for horizontal holes that self-support
|
|
117
|
+
|
|
118
|
+
## Design Checklist Before Printing
|
|
119
|
+
|
|
120
|
+
- [ ] All clearances set for target material (see tolerancing guide)
|
|
121
|
+
- [ ] No unsupported overhangs > 45° (or supports planned)
|
|
122
|
+
- [ ] Snap fit arms oriented parallel to bed
|
|
123
|
+
- [ ] Living hinges web horizontal
|
|
124
|
+
- [ ] Boss walls ≥ 1.5× insert OD
|
|
125
|
+
- [ ] Thread/hole diameters compensated for hole undersizing
|
|
126
|
+
- [ ] Part fits printer build volume (check with SolidWorks mass properties envelope)
|
|
127
|
+
- [ ] Infill and wall count appropriate for load case
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Hinge Design Guide for FDM 3D Printing
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Hinges are rotational joints that allow controlled angular motion between two components.
|
|
6
|
+
For FDM printing, hinges divide into two major categories:
|
|
7
|
+
|
|
8
|
+
1. **Print-in-place hinges** — printed as a single assembly with a clearance gap; no assembly required
|
|
9
|
+
2. **Hardware-assisted hinges** — use an M-series pin, dowel, or standard hinge hardware
|
|
10
|
+
|
|
11
|
+
## Print-in-Place Hinges
|
|
12
|
+
|
|
13
|
+
### Living Hinge (Flexure Hinge)
|
|
14
|
+
|
|
15
|
+
A thin flexible web that bends instead of rotating.
|
|
16
|
+
|
|
17
|
+
**Best materials:** PETG, TPU, Nylon (flexible layer bonding required)
|
|
18
|
+
**Avoid:** PLA (brittle after repeated flex cycles)
|
|
19
|
+
|
|
20
|
+
**Geometry guidelines:**
|
|
21
|
+
|
|
22
|
+
- Minimum web thickness: 0.8–1.2 mm (PETG), 1.0–1.5 mm (Nylon), 0.4–0.8 mm (TPU)
|
|
23
|
+
- Web width: 2–5× web thickness for stability
|
|
24
|
+
- Transition fillets: R ≥ 1.5× web thickness to minimize stress concentration
|
|
25
|
+
- Max reliable flex angle: ±30° for PETG, ±45° for Nylon, ±90° for TPU
|
|
26
|
+
- Cycle life: PETG ~1000 cycles before fatigue crack; Nylon ~10,000+; TPU ~100,000+
|
|
27
|
+
|
|
28
|
+
**Print orientation:** The web MUST be printed flat (parallel to bed) for maximum inter-layer
|
|
29
|
+
adhesion in flex. Never print a living hinge on edge.
|
|
30
|
+
|
|
31
|
+
**Layer height:** Use 0.15 mm or finer for living hinges to maximize layer count through
|
|
32
|
+
the thin web. More layers = better fatigue life.
|
|
33
|
+
|
|
34
|
+
### Barrel / Knuckle Print-in-Place Hinge
|
|
35
|
+
|
|
36
|
+
Printed assembled with a clearance between pin and barrel.
|
|
37
|
+
|
|
38
|
+
**Clearance recommendation:**
|
|
39
|
+
|
|
40
|
+
| Material combo (pin/barrel) | Clearance |
|
|
41
|
+
|-----------------------------|-----------|
|
|
42
|
+
| PLA / PLA | 0.30–0.40 mm |
|
|
43
|
+
| PETG / PETG | 0.35–0.50 mm |
|
|
44
|
+
| ABS / ABS | 0.30–0.40 mm |
|
|
45
|
+
| TPU pin / PLA barrel | 0.15–0.25 mm |
|
|
46
|
+
|
|
47
|
+
**Design rules:**
|
|
48
|
+
|
|
49
|
+
- Minimum barrel length: 8–10 mm to prevent pin from camming out under load
|
|
50
|
+
- Barrel wall thickness: ≥ 1.5 mm (3 perimeters at 0.4 mm nozzle)
|
|
51
|
+
- Pin diameter: 3–6 mm typical; larger for structural load
|
|
52
|
+
- Print orientation: hinge axis horizontal (pin parallel to bed) for round barrel geometry
|
|
53
|
+
- Add a small (1 mm) chamfer at barrel entrance to help pin pop in
|
|
54
|
+
|
|
55
|
+
**Assembly tip:** Print support removal easier if you use a 1.0 mm support gap and
|
|
56
|
+
0.3–0.5 mm Z-gap on support interface.
|
|
57
|
+
|
|
58
|
+
### Living Flexure with Stops
|
|
59
|
+
|
|
60
|
+
Add hard-stop features to limit rotation and protect the living section from over-rotation.
|
|
61
|
+
|
|
62
|
+
- Stop faces can be angled 0–90° to set max rotation
|
|
63
|
+
- Position stops ≥ 5 mm from hinge center to allow clean rotation before contact
|
|
64
|
+
|
|
65
|
+
## Hardware-Assisted Hinges
|
|
66
|
+
|
|
67
|
+
### M3 / M4 Shoulder Bolt Hinge
|
|
68
|
+
|
|
69
|
+
Use a stainless shoulder bolt as the hinge pin.
|
|
70
|
+
|
|
71
|
+
**Pin hole tolerance:**
|
|
72
|
+
|
|
73
|
+
- For M3 shoulder bolt (3.0 mm shank): print hole at Ø3.1–3.2 mm (clearance fit)
|
|
74
|
+
- For M4 shoulder bolt (4.0 mm shank): print hole at Ø4.1–4.2 mm
|
|
75
|
+
|
|
76
|
+
**Wear recommendation:** Insert a brass or steel M3/M4 heat-set insert as a sleeve if
|
|
77
|
+
the hinge will be used frequently. Heat set inserts greatly extend wear life.
|
|
78
|
+
|
|
79
|
+
**Wall thickness around pin:** minimum 2.5 mm on each side of pin hole.
|
|
80
|
+
|
|
81
|
+
### Dowel Pin Hinge
|
|
82
|
+
|
|
83
|
+
A 3 mm steel dowel pin is cheap and strong. Print hole at Ø3.1 mm and press the pin in.
|
|
84
|
+
|
|
85
|
+
### Piano Hinge (Continuous Hinge)
|
|
86
|
+
|
|
87
|
+
Mount a commercial piano hinge with M3 self-tapping or heat-set inserts.
|
|
88
|
+
|
|
89
|
+
- Boss diameter for M3 insert: 5.5 mm OD, 4.0 mm deep
|
|
90
|
+
- Boss OD should be ≥ 2× insert OD for sufficient wall
|
|
91
|
+
|
|
92
|
+
## Hinge Variants for SolidWorks Parametric Design
|
|
93
|
+
|
|
94
|
+
| Variant | Recommended For | Key Parameter |
|
|
95
|
+
|--------------------|----------------------------------------|----------------|
|
|
96
|
+
| Living hinge | Light loads, frequent flex, TPU/Nylon | web thickness |
|
|
97
|
+
| Barrel hinge | Panel doors, enclosure lids | barrel clearance|
|
|
98
|
+
| Wrapped hinge | Continuous flex (cable management) | wrap radius |
|
|
99
|
+
| Ratchet hinge | One-way or indexed rotation | tooth count |
|
|
100
|
+
| Fold-flat hinge | Portable structures, flat pack | fold angle |
|
|
101
|
+
|
|
102
|
+
## SolidWorks Workflow
|
|
103
|
+
|
|
104
|
+
1. Use **Revolve** for barrel/pin geometry
|
|
105
|
+
2. Use **Shell** to thin the web for living hinges
|
|
106
|
+
3. Use **Mates** to simulate rotation range and check interference
|
|
107
|
+
4. Use **Flex** to visualize living hinge deflection
|
|
108
|
+
5. Export as separate bodies for split-file printing if needed
|
|
109
|
+
|
|
110
|
+
## Common Hinge Failure Modes
|
|
111
|
+
|
|
112
|
+
| Failure | Cause | Fix |
|
|
113
|
+
|--------------------------|--------------------------------|-----------------------------------------|
|
|
114
|
+
| Stiff / won't rotate | Clearance too small | Increase clearance 0.1 mm |
|
|
115
|
+
| Pin falls out | Clearance too large | Decrease clearance or add detent |
|
|
116
|
+
| Living web cracks | Thickness too small / PLA | Switch to PETG/Nylon, increase thickness |
|
|
117
|
+
| Barrel cracks at entry | Wall too thin | Increase wall thickness to ≥ 2 mm |
|
|
118
|
+
| Wobble / slop | Barrel too short | Extend barrel length |
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Snap-Fit Design Guide for FDM 3D Printing
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Snap fits are one of the most useful joint types for 3D-printed assemblies. They allow
|
|
6
|
+
tool-free assembly and disassembly. FDM-specific design rules differ from injection
|
|
7
|
+
molding guidelines due to layer anisotropy and material properties.
|
|
8
|
+
|
|
9
|
+
## Types of Snap Fits
|
|
10
|
+
|
|
11
|
+
### 1. Cantilever Snap Fit (Most Common for FDM)
|
|
12
|
+
|
|
13
|
+
A cantilever snap fit is an arm that deflects laterally and then snaps into a recession
|
|
14
|
+
or over a ledge.
|
|
15
|
+
|
|
16
|
+
**Key geometry parameters:**
|
|
17
|
+
|
|
18
|
+
- Arm length (L): longer arm = easier deflection, less stress
|
|
19
|
+
- Arm width (b): wider = stiffer
|
|
20
|
+
- Arm thickness (h): thinner at base for controlled flex
|
|
21
|
+
- Deflection (δ): the snap travel before engagement
|
|
22
|
+
- Lead angle: 15–30° for easy entry, 90° for permanent lock, 45° for reusable
|
|
23
|
+
|
|
24
|
+
**FDM design rules:**
|
|
25
|
+
|
|
26
|
+
- Orient the cantilever so it bends parallel to the print layers (not through layers)
|
|
27
|
+
- Minimum arm length: 5× arm thickness at root to avoid crack at root
|
|
28
|
+
- Clearance on non-deflecting sides: 0.3–0.5 mm (PETG), 0.2–0.4 mm (PLA)
|
|
29
|
+
- Add a 0.5–1.0 mm fillet at the arm root to reduce stress concentration
|
|
30
|
+
- Recommended retention angle for reusable snap: 30–45°
|
|
31
|
+
- Recommended retention angle for permanent: 70–90°
|
|
32
|
+
|
|
33
|
+
**Material-specific max strain:**
|
|
34
|
+
|
|
35
|
+
- PLA: 2–3% safe strain limit
|
|
36
|
+
- PETG: 3–5% safe strain limit
|
|
37
|
+
- ABS: 3–5% safe strain limit
|
|
38
|
+
- TPU/TPE: 10–20% (very flexible, use thick snaps)
|
|
39
|
+
- Nylon PA12: 4–6%
|
|
40
|
+
|
|
41
|
+
**Deflection formula (cantilever):**
|
|
42
|
+
δ = (strain × L²) / (1.5 × h)
|
|
43
|
+
|
|
44
|
+
where L = arm length, h = arm thickness at root, strain = material limit.
|
|
45
|
+
|
|
46
|
+
### 2. Annular (Ring) Snap Fit
|
|
47
|
+
|
|
48
|
+
Used for caps, lids, and cylindrical closures.
|
|
49
|
+
|
|
50
|
+
**FDM adaptation:**
|
|
51
|
+
|
|
52
|
+
- Print vertically when possible so the ring is printed in-plane
|
|
53
|
+
- Undercut depth: 0.5–1.0 mm for PLA/PETG
|
|
54
|
+
- Lead chamfer: 30° for easy assembly
|
|
55
|
+
- Oversize the male feature by 0.1–0.2 mm to preload the joint
|
|
56
|
+
|
|
57
|
+
### 3. Torsional Snap Fit
|
|
58
|
+
|
|
59
|
+
Less common but useful for panel inserts. The arm twists rather than bends.
|
|
60
|
+
|
|
61
|
+
**FDM consideration:** Torsion through layers is weak; keep torsional snap fits
|
|
62
|
+
in-plane with prints.
|
|
63
|
+
|
|
64
|
+
### 4. Ball-and-Socket Snap (Print-in-Place)
|
|
65
|
+
|
|
66
|
+
Popular for print-in-place joints:
|
|
67
|
+
|
|
68
|
+
- Minimum clearance between ball and socket: 0.4–0.6 mm (PETG), 0.3–0.5 mm (PLA)
|
|
69
|
+
- Print vertically for best-of-round socket
|
|
70
|
+
- Socket opening angle: 90–120° for good retention while allowing disassembly
|
|
71
|
+
|
|
72
|
+
## General FDM Snap Fit Clearances
|
|
73
|
+
|
|
74
|
+
| Interface | PLA | PETG | ABS | Nylon |
|
|
75
|
+
|-----------------|-------------|-------------|-------------|-------------|
|
|
76
|
+
| Sliding fit | 0.25–0.35 mm| 0.30–0.40 mm| 0.25–0.35 mm| 0.20–0.35 mm|
|
|
77
|
+
| Snap engagement | 0.20–0.30 mm| 0.25–0.35 mm| 0.20–0.30 mm| 0.15–0.25 mm|
|
|
78
|
+
| Press fit | 0.00–0.10 mm| 0.05–0.15 mm| 0.00–0.10 mm| -0.05–0.10 mm|
|
|
79
|
+
|
|
80
|
+
## Common Snap Fit Failure Modes
|
|
81
|
+
|
|
82
|
+
1. **Root fracture**: Arm too short or fillet missing → add fillet, increase arm length
|
|
83
|
+
2. **No click/engagement**: Clearance too large → reduce by 0.1 mm increments
|
|
84
|
+
3. **Permanent deformation**: Strain too high → increase arm length or switch material
|
|
85
|
+
4. **Layer delamination**: Arm bending through layers → reorient print
|
|
86
|
+
5. **Wobble after assembly**: Mating side clearance too large → add a locating boss
|
|
87
|
+
|
|
88
|
+
## SolidWorks Implementation Tips
|
|
89
|
+
|
|
90
|
+
- Model snap fits as separate bodies to control print orientation per body
|
|
91
|
+
- Use the "Flex" feature to simulate deflection and check interference
|
|
92
|
+
- Add "Draft" to snap faces to ease assembly direction
|
|
93
|
+
- Use Equations to drive snap geometry from a single "clearance" variable
|