solidworks_mcp.adapters.solidworks.sheet_metal¶
solidworks_mcp.adapters.solidworks.sheet_metal ¶
Sheet metal: base flange, edge flange, sketched bend, flat pattern (#57).
Queue item 15. Positions are millimetres in model space; COM takes metres
and radians. Each feature is judged by the volume before and after
(_measured from the part-features mixin), because SolidWorks can
report success and build nothing.
Attributes¶
_START_WITH
module-attribute
¶
Classes¶
AdapterResult
dataclass
¶
AdapterResult(status: AdapterResultStatus, data: T | None = None, error: str | None = None, execution_time: float | None = None, metadata: dict[str, Any] | None = None)
Result wrapper for adapter operations.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
T | None
|
The data value. |
error |
str | None
|
The error value. |
execution_time |
float | None
|
The execution time value. |
metadata |
dict[str, Any] | None
|
The metadata value. |
status |
AdapterResultStatus
|
The status value. |
AdapterResultStatus ¶
Bases: StrEnum
Result status for adapter operations.
Attributes:
| Name | Type | Description |
|---|---|---|
ERROR |
Any
|
The error value. |
SUCCESS |
Any
|
The success value. |
TIMEOUT |
Any
|
The timeout value. |
WARNING |
Any
|
The warning value. |
InputRefused ¶
Bases: ValueError
The adapter checked an input against the document and refused it.
An expected answer, not a fault: a section line that misses its view, a
point with nothing to dimension. It is logged as one line, without a
traceback, and the tools classify it as invalid_input.
SolidWorksSheetMetalMixin ¶
create_base_flange, add_edge_flange, create_sketched_bend, set_flat_pattern.
Methods:¶
add_edge_flange
async
¶
add_edge_flange(edge_point: list[float], length: float, angle: float = 90.0, bend_radius: float | None = None, flip: bool = False) -> AdapterResult[dict[str, Any]]
A flange off the sheet edge nearest edge_point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_point
|
list[float]
|
|
required |
length
|
float
|
The flange's length, mm. |
required |
angle
|
float
|
The flange's angle from the sheet, degrees. |
90.0
|
bend_radius
|
float | None
|
Inside bend radius, mm; the sheet's when omitted. |
None
|
flip
|
bool
|
Put the flange on the other side. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
volume change. |
Source code in src/solidworks_mcp/adapters/solidworks/sheet_metal.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
create_base_flange
async
¶
create_base_flange(thickness: float, bend_radius: float, k_factor: float = 0.5, depth: float | None = None, sketch: str | None = None, reverse: bool = False) -> AdapterResult[dict[str, Any]]
A base flange from a sketch: a plate, or an open profile extruded by depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thickness
|
float
|
Sheet thickness, mm. |
required |
bend_radius
|
float
|
Inside bend radius, mm. |
required |
k_factor
|
float
|
The bend allowance's K-factor. |
0.5
|
depth
|
float | None
|
How far an open profile is extruded, mm; not used for a closed one. |
None
|
sketch
|
str | None
|
The sketch's name; the last closed sketch when omitted. |
None
|
reverse
|
bool
|
Thicken to the other side of the sketch. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
the volume before, after and change. |
Source code in src/solidworks_mcp/adapters/solidworks/sheet_metal.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
create_sketched_bend
async
¶
create_sketched_bend(angle: float = 90.0, bend_radius: float | None = None, sketch: str | None = None, reverse: bool = False) -> AdapterResult[dict[str, Any]]
Bend the sheet along a sketched line.
SolidWorks chooses which side of the line stays put:
ISketchedBendFeatureData.SetFixedFace made no difference live on
SolidWorks 2026, with or without the face selected. The reply's
bounding box shows which side moved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
The bend angle, degrees. |
90.0
|
bend_radius
|
float | None
|
Inside bend radius, mm; the sheet's when omitted. |
None
|
sketch
|
str | None
|
The bend line's sketch; the last closed sketch when omitted. |
None
|
reverse
|
bool
|
Bend the other way. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
Source code in src/solidworks_mcp/adapters/solidworks/sheet_metal.py
set_flat_pattern
async
¶
Flatten the sheet-metal part, or fold it back, and measure it.
As SolidWorks' Flatten command does, this unsuppresses the part's
Flat-Pattern feature (suppresses it to fold). IModelDoc2.SetBendState
returned success and changed nothing (seen live, SolidWorks 2026).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flat
|
bool
|
True to flatten, False to fold. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
pattern's name) and |
AdapterResult[dict[str, Any]]
|
the blank's size). |
Source code in src/solidworks_mcp/adapters/solidworks/sheet_metal.py
_BodyEntityPicker ¶
Find the body edge or face nearest a point, by true closest distance.
SelectByID2("", "EDGE", x, y, z, ...) picks along the view direction
through the point, so on a 12 mm plate seen from the front an edge at
z=-6 is hidden behind the matching edge at z=+6 and the front one is
selected instead - silently. This walks every solid body's edges (or
faces) and measures the distance from the point to the closest point
on each (IEdge / IFace2.GetClosestPointOn), which does not
depend on the view, vertices or midpoints.
The entity lists are read once per picker, so one fillet over many edges costs one body walk, not one per edge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
Methods:¶
entities ¶
Return every solid body's GetEdges() or GetFaces().
Source code in src/solidworks_mcp/adapters/solidworks/features.py
nearest ¶
Return (entity, distance_m) for the closest entity, or None.
Source code in src/solidworks_mcp/adapters/solidworks/features.py
select ¶
Select entity with IEntity.Select4 under mark.
Source code in src/solidworks_mcp/adapters/solidworks/features.py
Functions:¶
_m ¶
_null_callout ¶
Return a VT_DISPATCH null for SelectByID2's Callout parameter.
A plain Python None marshals as VT_NULL, which SolidWorks rejects
with DISP_E_TYPEMISMATCH - measured as
(-2147352571, 'Type mismatch.', None, 8). See runbook item 11.
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A |
Any
|
when pywin32 is unavailable (mock/Linux runs, where no real COM call |
|
Any
|
will be made anyway, but the value must still never be bare |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_select_named_feature ¶
Select a named feature under a specific selection mark via Select2.
Sweep and loft rely on selection marks to tell SolidWorks which selection
is the profile (1), guide curve (2), or sweep path (4). We resolve the
feature with IModelDoc2::FeatureByName and select it with
IFeature::Select2(append, mark) — the same proven path the rest of the
adapter uses for plane/sketch selection. IModelDocExtension::SelectByID2
is avoided deliberately: late-bound SelectByID2 raises
Type mismatch on some SolidWorks builds, whereas FeatureByName +
Select2 is reliable, works for sketches and reference curves such as
a helix, and needs no entity-type string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
name
|
str
|
Feature name (e.g. |
required |
mark
|
int
|
Selection mark — 1=profile, 2=guide curve, 4=sweep path. |
required |
append
|
bool
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Source code in src/solidworks_mcp/adapters/solidworks/features.py
as_list ¶
Normalise a COM array/scalar/None return into a list.
dispatch_array ¶
VARIANT(VT_ARRAY | VT_DISPATCH), e.g. edges for a flange (tuple when pywin32 is absent).