solidworks_mcp.adapters.solidworks.documentation¶
solidworks_mcp.adapters.solidworks.documentation ¶
Model-data mixin for PyWin32 SolidWorks operations.
Covers the engineering data a drawing or BOM is built from: model dimensions, measurements, material, custom properties and sheet-metal flat patterns.
Every method name, argument order and enum value below was read from the
SOLIDWORKS 2025 type libraries (sldworks.tlb via gen_py, swconst.tlb
via pythoncom.LoadTypeLib), not from memory. Live behaviour is covered by
tests/live/test_live_sw_documentation_tools.py.
Attributes¶
MATERIAL_PROPERTIES
module-attribute
¶
MATERIAL_PROPERTIES: dict[str, tuple[str, str]] = {'elastic_modulus': ('EX', 'Pa'), 'poissons_ratio': ('NUXY', ''), 'shear_modulus': ('GXY', 'Pa'), 'tensile_strength': ('SIGXT', 'Pa'), 'yield_strength': ('SIGYLD', 'Pa'), 'compressive_strength': ('SIGXC', 'Pa'), 'density': ('DENS', 'kg/m^3'), 'thermal_expansion': ('ALPX', '1/K'), 'thermal_conductivity': ('KX', 'W/(m*K)'), 'specific_heat': ('C', 'J/(kg*K)')}
_MEASURE_PREFIXES
module-attribute
¶
_SW_INSERT_DIMENSIONS_MARKED_FOR_DRAWING
module-attribute
¶
_SW_INSERT_HOLE_WIZARD_LOCATION_DIMS
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.
SolidWorksDocumentationMixin ¶
Expose model-data and drawing-documentation methods through a mixin.
Methods:¶
arrange_dimensions
async
¶
Move drawing dimensions so none overlaps another, then verify.
Reads every dimension's text box and lines, plans positions outside
the views with :func:dimension_layout.plan_layout, applies them with
IAnnotation::SetPosition, rebuilds, then re-reads the real
geometry and checks the rule with :func:dimension_layout.find_overlaps.
The check covers every view on the sheet, even when only one view is
rearranged, because neighbouring views' dimensions can collide.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_name
|
str | None
|
Only move this view's dimensions; all views when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
(each violation listed), |
AdapterResult[dict[str, Any]]
|
overlap remains - the rule is not met - with the same data, so the |
AdapterResult[dict[str, Any]]
|
caller can see which dimensions still collide. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
export_flat_pattern
async
¶
Export the active sheet-metal part's flat pattern to DXF or DWG.
Wraps IPartDoc::ExportToDWG2 with swExportToDWG_ExportSheetMetal.
SheetMetalOptions 1 exports the flat-pattern geometry only (no bend
lines or sketches).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Output |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The written path and its size. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 | |
get_custom_properties
async
¶
Read the custom properties of the active document.
Wraps IModelDocExtension::CustomPropertyManager(config) with
GetNames + Get6. "" reads the file-level properties a
drawing title block usually links to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration
|
str | None
|
Configuration name; file-level when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
|
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
get_material
async
¶
get_material(configuration: str | None = None, material: str | None = None, database: str | None = None) -> AdapterResult[dict[str, Any]]
Read the active part's material, or a library material by name.
The part's material comes from IPartDoc::GetMaterialPropertyName2
(see :func:_read_material); its properties from its entry in the
.sldmat library, which SolidWorks reads too (no COM call returns
a part material's modulus or strengths outside Simulation).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration
|
str | None
|
Configuration name; the active one when omitted. |
None
|
material
|
str | None
|
A library material to read instead of the part's; no document is needed and none is changed. |
None
|
database
|
str | None
|
The library to look in first for |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
data: |
AdapterResult[dict[str, Any]]
|
( |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
insert_model_dimensions
async
¶
insert_model_dimensions(view_name: str | None = None, include_hole_wizard: bool = True) -> AdapterResult[dict[str, Any]]
Bring model dimensions into drawing views, each dimension shown once.
Imports the model's "marked for drawing" dimensions view by view with
IDrawingDoc::InsertModelAnnotations3 (UsePlacementInSketch off,
so SolidWorks places them rather than copying sketch positions).
Drafting rules applied:
- pictorial views (isometric, dimetric, trimetric) are not dimensioned unless named explicitly;
- a model dimension already shown in an earlier view is deleted from later views, so each dimension appears exactly once on the sheet.
Falls back to IDrawingDoc::AutoDimension only when nothing at all
could be imported. Placement is then made overlap-free by
:meth:arrange_dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_name
|
str | None
|
One view to dimension; every orthographic view when omitted. |
None
|
include_hole_wizard
|
bool
|
Also import Hole Wizard location dimensions. |
True
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Per-view counts, duplicates removed, |
AdapterResult[dict[str, Any]]
|
skipped pictorial views and the |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
list_available_materials
async
¶
List materials from the configured SolidWorks material libraries.
Reads the custom library folders from
swFileLocationsMaterialDatabases (a ;-separated list) plus the
install's built-in sldmaterials folder, and parses every
.sldmat file in them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search
|
str | None
|
Case-insensitive substring filter on name or classification. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[list[dict[str, str]]]
|
AdapterResult[list[dict[str, str]]]: |
AdapterResult[list[dict[str, str]]]
|
and |
AdapterResult[list[dict[str, str]]]
|
read and the |
AdapterResult[list[dict[str, str]]]
|
told apart from an unexpected library location. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
list_model_dimensions
async
¶
List every dimension in the active part or assembly, once each.
Reads the features with the same two-pass walk as list_features
(:func:~.feature_walk.walk_feature_tree), skips folder rows, and
reads each feature's GetFirstDisplayDimension chain. SolidWorks
can show one dimension under several features (a plane's offset under
the cut sketched on it), so each full_name (e.g. "D1@Sketch1",
the name set_dimension accepts) is kept once, with feature set
from the part after the @.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feature_name
|
str | None
|
Only list dimensions owned by this feature
(case-insensitive), by the |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[list[dict[str, Any]]]
|
AdapterResult[list[dict[str, Any]]]: |
AdapterResult[list[dict[str, Any]]]
|
|
AdapterResult[list[dict[str, Any]]]
|
and |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
measure_entities
async
¶
Measure one or more entities with SolidWorks' Measure tool.
Selects each entity by spec (see :func:_parse_measure_spec), then runs
IModelDocExtension::CreateMeasure + IMeasure::Calculate(None),
which measures the current selection. Values SolidWorks reports as
-1 (not applicable to the selection) are dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
One or two entity specs, e.g. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Measured values in metres, square |
AdapterResult[dict[str, Any]]
|
metres and radians, plus |
AdapterResult[dict[str, Any]]
|
two entities. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | |
set_custom_property
async
¶
set_custom_property(name: str, value: str, configuration: str | None = None) -> AdapterResult[dict[str, Any]]
Create or overwrite one text custom property on the active document.
Wraps ICustomPropertyManager::Add3(name, swCustomInfoText, value,
swCustomPropertyReplaceValue) and reads the value back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Property name, e.g. |
required |
value
|
str
|
Text value; may be a |
required |
configuration
|
str | None
|
Configuration name; file-level when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The stored and resolved value. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
set_material
async
¶
set_material(material_name: str, database: str | None = None, configuration: str | None = None) -> AdapterResult[dict[str, Any]]
Assign a material to the active part.
Wraps IPartDoc::SetMaterialPropertyName2 (a void call), then
reads the material back - the read-back is the only proof it applied.
A name the library does not hold leaves the part unchanged and is
reported as not found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material_name
|
str
|
Material name exactly as in the library, e.g.
|
required |
database
|
str | None
|
Library name; |
None
|
configuration
|
str | None
|
Configuration name; |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Requested and applied material. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
Functions:¶
_as_com ¶
Wrap a raw dispatch and flag its methods for an interface.
Objects handed back inside arrays (GetViews and friends) arrive as raw
PyIDispatch. Method flagging is a no-op on those, so every call
against them raises until they are wrapped through dynamic.Dispatch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected |
required |
obj
|
Any
|
The raw dispatch. |
required |
interface
|
str
|
Interface name, e.g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The wrapped, flagged object, or |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
_byref_bstr ¶
Return a byref string VARIANT for a SolidWorks String out-parameter.
Under forced late binding an omitted out-parameter raises "Parameter not
optional", and pythoncom.Missing cannot be converted to a COM VARIANT,
so pass VARIANT(VT_BYREF | VT_BSTR, "") and read .value afterwards
(e.g. IPartDoc::GetMaterialPropertyName2's Database; confirmed live
on R2026x).
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The byref VARIANT, or a |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
_doc_type ¶
Return the active document's type: 1 part, 2 assembly, 3 drawing.
GetType is one of the members pywin32 late binding may expose as either
a bound method or a plain value, so calling it directly returns None on
some documents. _get_attr_or_call handles both shapes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The document type, or |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
_entry_properties ¶
The known properties of one <material> element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material
|
Any
|
The parsed |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, Any]]
|
dict[str, dict[str, Any]]: Key to |
dict[str, dict[str, Any]]
|
|
dict[str, dict[str, Any]]
|
or not a number are left out. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_is_folder ¶
Whether a feature-tree row is a folder, which owns no dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_name
|
str
|
The row's |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True for folder types ( |
bool
|
...) and the annotations folder ( |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_library_files ¶
The .sldmat files in folders, folder by folder, sorted by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folders
|
list[str]
|
Material library folders; missing ones are skipped. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Full paths. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_material_entry ¶
_material_entry(files: list[str], name: str, database: str) -> tuple[str, dict[str, dict[str, Any]]] | None
A material's library and properties, from its .sldmat entry.
The library whose file name matches database is searched first, then
the others. Values are as the libraries store them, in SI units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list[str]
|
|
required |
name
|
str
|
The material's name, as |
required |
database
|
str
|
Its library's name, the file name without extension; |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, dict[str, dict[str, Any]]] | None
|
tuple[str, dict[str, dict[str, Any]]] | None: The library the entry |
tuple[str, dict[str, dict[str, Any]]] | None
|
was found in and its properties (see :func: |
tuple[str, dict[str, dict[str, Any]]] | None
|
|
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_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
_overlap_summary ¶
Describe the overlaps arrange_dimensions could not clear.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
dict[str, Any]
|
The layout result, carrying |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
How many overlaps remain, their kinds, the first five, and what |
str
|
to try next. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_owning_feature ¶
The feature a dimension's full name says owns it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_name
|
str | None
|
A short full name such as |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The part after the first |
str | None
|
when there is no name or no |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_parse_edge_spec ¶
Parse an edge/face specification string into (name, x, y, z, entity_type).
Supports three formats:
- "Edge<1>" — name-based EDGE selection (x=y=z=0.0, SW looks up by
topology name)
- "x,y,z" — coordinate-based EDGE selection (name="", coordinate hint
in metres)
- "face:x,y,z" (case-insensitive prefix) — coordinate-based FACE
selection. Selecting a whole face and handing it to
InsertFeatureChamfer/FeatureFillet3 chamfers/fillets every
edge bounding that face in one call. It is the robust way to reach a
hole's rim: the rim is one edge of the face the hole opens onto, and
a point well inside that face is clear of every boundary, whereas an
edge point has to land on the rim itself.
Every coordinate pick must lie within _PICK_TOLERANCE_M of the edge
or face it resolves to. (A 2026-09-18 note here said an edge pick aimed
at a hole rim landed on a 30 mm outer edge; the test's point was on that
outer edge, because it assumed the wrong height axis. See #199.)
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_parse_material_library ¶
Read material names and classifications from one .sldmat file.
.sldmat is XML: <classification name=...> elements hold
<material name=...> children. Tags are matched by local name because
the root element carries a namespace. Parsed with defusedxml: library
folders can be user-configured, so entity-expansion and external-entity
payloads are refused rather than expanded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, str]]
|
list[dict[str, str]]: |
list[dict[str, str]]
|
for each material; empty when the file cannot be parsed or is refused. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_parse_measure_spec ¶
Parse a measure_entities entity spec into SelectByID2 arguments.
Accepts the same "face:x,y,z" / "x,y,z" / "Edge<1>" forms as
add_fillet (via :func:_parse_edge_spec), plus "edge:x,y,z" and
"vertex:x,y,z". Coordinates are in metres.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
str
|
The entity spec. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, float, float, float, str]
|
tuple[str, float, float, float, str]: name, x, y, z and entity type. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_read_custom_property ¶
Read one custom property's (value, resolved value).
Tries Get6 (value and resolved value) first; under late binding on
SW 2025 its out-parameters raise Parameter not optional, so it falls
back to Get(name), which returns the stored text only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
The adapter, for its |
required |
manager
|
Any
|
The document's |
required |
name
|
str
|
Property name. |
required |
Returns:
| Type | Description |
|---|---|
str
|
tuple[str, str]: The stored value and the resolved value; empty |
str
|
strings when the property cannot be read. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_read_material ¶
Read (material, database) from IPartDoc::GetMaterialPropertyName2.
Database is a String out-parameter: under late binding on SW 2026
omitting it raises "Parameter not optional", so it is passed as a byref
BSTR and read back from .value. Older pywin32 builds may instead return
(name, database) as a tuple; both shapes are accepted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
part
|
Any
|
The active |
required |
configuration
|
str | None
|
Configuration name; the active one when |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
tuple[str, str]: Material name and library; empty strings when unset. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_resolve_drawing_view ¶
Return the IView on the active drawing whose name matches.
Walks IDrawingDoc::GetViews (a list of sheets, each shaped
(sheet, view, view, ...)) the same way :func:_view_names does. The
match is case-insensitive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected |
required |
drawing
|
Any
|
The drawing document, flagged for |
required |
view_name
|
str
|
The drawing-view name to look for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The flagged |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
_select_edge_by_coord ¶
_select_edge_by_coord(adapter: Any, x: float, y: float, z: float, append: bool, mark: int = 0, entity_type: str = 'EDGE', picker: _BodyEntityPicker | None = None, rebuild: bool = True) -> bool
Select the edge (or face) nearest to (x, y, z) in metres.
Calls ForceRebuild3 on the first entity in the selection set so that
recent features are fully tessellated and selectable, then resolves the
point with :class:_BodyEntityPicker - the entity whose closest point is
nearest, independent of the view. Only when no body edge/face can be read
at all does it fall back to the view-dependent SelectByID2 pick.
entity_type is normally "EDGE", but pass "FACE" to select a
whole face instead. Any other type ("VERTEX" from
measure_entities) goes straight to the SelectByID2 pick: a vertex
lies on its edges at distance 0, so the edge walk would select an edge
in its place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
x
|
float
|
X in metres. |
required |
y
|
float
|
Y in metres. |
required |
z
|
float
|
Z in metres. |
required |
append
|
bool
|
Add to the current selection instead of replacing it. |
required |
mark
|
int
|
Selection mark. |
0
|
entity_type
|
str
|
|
'EDGE'
|
picker
|
_BodyEntityPicker | None
|
Reuse a picker (and its body walk) across several picks. |
None
|
rebuild
|
bool
|
Rebuild before the first pick. Pass False inside an open sketch: a rebuild there closes the sketch (seen live). |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if an entity was selected; False otherwise. |
Raises:
| Type | Description |
|---|---|
LookupError
|
When the nearest entity is further than
|
Source code in src/solidworks_mcp/adapters/solidworks/features.py
2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 | |
_sequence ¶
Normalise a COM array return (None, scalar or tuple) into a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
Any
|
What the COM call returned. |
required |
Returns:
| Type | Description |
|---|---|
list[Any]
|
list[Any]: The non- |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_strip_document_suffix ¶
Turn "D1@Sketch1@Part10.Part" into "D1@Sketch1".
Live SW 2025 appends @<document title> to IDimension::FullName;
IModelDoc2::Parameter (behind set_dimension) takes the short form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_name
|
Any
|
|
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The name without the document suffix; |
str | None
|
|
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_unpack_custom_property ¶
Pull (value, resolved value) out of an ICustomPropertyManager::Get6 result.
Under late binding the out-parameters come back as a tuple that may or may not lead with the integer return code, depending on the pywin32 build.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
Any
|
Whatever |
required |
Returns:
| Type | Description |
|---|---|
str
|
tuple[str, str]: The raw (possibly |
str
|
resolved value; empty strings when the shape is unrecognised. |
Source code in src/solidworks_mcp/adapters/solidworks/documentation.py
_view_names ¶
Return the drawing's view names, excluding sheet formats.
CreateDrawViewFromModelView3 returns None for a model SolidWorks
could not resolve, and Create3rdAngleViews2 returns a bare boolean, so
the view list is the ground truth for whether views were really added.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected |
required |
drawing
|
Any
|
The drawing document, flagged for |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: View names in sheet order. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
walk_feature_tree ¶
Every top-level feature of document, once each, in tree order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
The adapter, for |
required |
document
|
Any
|
The |
required |
Returns:
| Type | Description |
|---|---|
list[TreeFeature]
|
list[TreeFeature]: The features, sorted by tree position. A feature |
list[TreeFeature]
|
found by both passes (same name and type) is kept once. |