solidworks_mcp.adapters.solidworks.default_entities¶
solidworks_mcp.adapters.solidworks.default_entities ¶
Find the default planes, the origin and the standard views by identity.
Added in 2.2.0 for #262 (German SolidWorks 2025) and #261 (French): it replaces the name tables and the process-wide pywin32 hook.
The tools name these in English ("Top", "Front Plane",
"*Isometric"), but their names in a document depend on the template and
the install's language: "Plan de dessus" on French, "Ebene oben" on
German, and anything at all once a user renames them. Their identity does
not change:
- the first three
RefPlanefeatures before theOriginProfileFeatureare Front, Top and Right, in that order, in every part, assembly and component, in every language; IModelDoc2.GetModelViewNameslists the ten standard views first, in a fixed order (normal to, front, back, left, right, top, bottom, isometric, trimetric, dimetric).
Every call reads the document it works on, so two open documents with differently named planes each get their own names and nothing is cached.
Attributes¶
STANDARD_VIEWS
module-attribute
¶
STANDARD_VIEWS = ('*Normal To', '*Front', '*Back', '*Left', '*Right', '*Top', '*Bottom', '*Isometric', '*Trimetric', '*Dimetric')
_ALIASES
module-attribute
¶
_ALIASES: dict[str, int] = {'front': 0, 'front plane': 0, 'xy': 0, 'top': 1, 'top plane': 1, 'xz': 1, 'right': 2, 'right plane': 2, 'yz': 2, 'origin': _ORIGIN_INDEX, '前视': 0, '前視': 0, '前视基准面': 0, '前視基準面': 0, '上视': 1, '上視': 1, '上视基准面': 1, '上視基準面': 1, '右视': 2, '右視': 2, '右视基准面': 2, '右視基準面': 2, '原点': _ORIGIN_INDEX, '原點': _ORIGIN_INDEX}
Classes¶
DefaultEntities
dataclass
¶
What the start of one feature tree says about its default entities.
Attributes:
| Name | Type | Description |
|---|---|---|
planes |
tuple[str, ...]
|
Every |
origin |
str | None
|
The origin feature's name, |
Functions:¶
_owner_for ¶
The tree a name with @suffix lives in: the named component when the
active document is an assembly that has it, else the active document.
Source code in src/solidworks_mcp/adapters/solidworks/default_entities.py
_read ¶
Read a member late binding may expose as a property or a method.
as_list ¶
Normalise a COM array/scalar/None return into a list.
attempt ¶
Run fn through the adapter's _attempt (exceptions -> default).
default_index ¶
Which default entity name means (0 Front, 1 Top, 2 Right, 3 Origin).
Any @component@assembly suffix is ignored; None for any other name.
Source code in src/solidworks_mcp/adapters/solidworks/default_entities.py
entity_name ¶
The document's own name for a default plane or the origin.
Front, Top, Right, XY, XZ, YZ, Front Plane...
and Origin, in any case, are found by their place in the tree; a
@component@assembly suffix reads that component's tree and is kept.
Any other name is returned unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a document open. |
required |
name
|
str
|
The name a tool was given. |
required |
owner
|
Any
|
The document or component to read; by default the active document, or the component the suffix names. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name to pass to SolidWorks. When the tree can't be read, the |
str
|
English name ( |
Raises:
| Type | Description |
|---|---|
LookupError
|
The tree reached its origin with fewer than three reference planes before it; the message lists them and the install's language. |
Source code in src/solidworks_mcp/adapters/solidworks/default_entities.py
flag ¶
Flag just names as methods on obj (no-op for None/fakes).
Flagging a whole interface costs ~27 ms per fresh dispatch (see
WALK_MEMBERS in feature_walk); SolidWorks hands back a fresh
dispatch on most calls, so flag only what is about to be read.
Source code in src/solidworks_mcp/adapters/solidworks/com_utils.py
install_language ¶
The SolidWorks install's language (GetCurrentLanguage), or unknown.
Source code in src/solidworks_mcp/adapters/solidworks/default_entities.py
read_defaults ¶
Walk owner's tree (a ModelDoc2 or Component2) up to its origin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
The adapter, for |
required |
owner
|
Any
|
The document or component whose tree to read. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DefaultEntities |
DefaultEntities
|
The planes before the origin, and the origin. |
Source code in src/solidworks_mcp/adapters/solidworks/default_entities.py
standard_view_name ¶
The model's own name for a standard view ("*Isometric" ...).
Read from model.GetModelViewNames by the view's position; the
English name when english isn't a standard view, or when the list is
too short or its first ten aren't all *-named views.