Skip to content

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

_BLIND module-attribute

_BLIND = 0

_EDGE_TOLERANCE_M module-attribute

_EDGE_TOLERANCE_M = 0.001

_K_FACTOR module-attribute

_K_FACTOR = 2

_MATERIAL_INSIDE module-attribute

_MATERIAL_INSIDE = 1

_OUTER_VIRTUAL_SHARP module-attribute

_OUTER_VIRTUAL_SHARP = 1

_RELIEF_RECTANGULAR module-attribute

_RELIEF_RECTANGULAR = 1

_SKETCH_BEND module-attribute

_SKETCH_BEND = 35

_START_WITH module-attribute

_START_WITH = 'Start with create_base_flange, which makes a part sheet metal.'

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.

Attributes
is_error property
is_error: bool

Check if operation had an error.

Returns:

Name Type Description
bool bool

True if error, otherwise False.

is_success property
is_success: bool

Check if operation was successful.

Returns:

Name Type Description
bool bool

True if success, otherwise False.

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]

[x, y, z] mm on the edge.

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]]: name, edge_length_mm and the

AdapterResult[dict[str, Any]]

volume change.

Source code in src/solidworks_mcp/adapters/solidworks/sheet_metal.py
async def add_edge_flange(
    self,
    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``.

    Args:
        edge_point: ``[x, y, z]`` mm on the edge.
        length: The flange's length, mm.
        angle: The flange's angle from the sheet, degrees.
        bend_radius: Inside bend radius, mm; the sheet's when omitted.
        flip: Put the flange on the other side.

    Returns:
        AdapterResult[dict[str, Any]]: ``name``, ``edge_length_mm`` and the
        volume change.
    """
    refusal = self._sheet_metal_refusal("add_edge_flange")
    if refusal is not None:
        return refusal
    adapter: Any = self

    def build() -> dict[str, Any]:
        # The sequence of SolidWorks' "Insert Sheet Metal Edge Flange"
        # example: the edge selected, its profile sketch made with
        # InsertSketchForEdgeFlange, the edge converted into that sketch
        # and the profile drawn from its ends, then the flange.
        model = adapter.currentModel
        x, y, z = (_m(v) for v in edge_point)
        point = (x, y, z)
        picker = _BodyEntityPicker(adapter)
        found = picker.nearest("GetEdges", point)
        if found is None or found[1] > _EDGE_TOLERANCE_M:
            raise InputRefused(
                f"No sheet edge at {list(edge_point)} mm; give a point on "
                "the edge itself."
            )
        model.ClearSelection2(True)
        if not picker.select(found[0], append=False):
            raise LookupError(f"Couldn't select the edge at {list(edge_point)} mm.")
        selections = sw_type_info.flagged(model.SelectionManager, "ISelectionMgr")
        edge = selections.GetSelectedObject6(1, -1)
        edge_length = self._edge_span_mm(edge)
        sketch = self._flange_profile(edge, angle, flip, length)
        options = (_EDGE_DEFAULT_RADIUS if bend_radius is None else 0) | (
            _EDGE_FLIP if flip else 0
        )
        manager = sw_type_info.flagged(model.FeatureManager, "IFeatureManager")
        feature = manager.InsertSheetMetalEdgeFlange2(
            dispatch_array([edge]),  # FlangeEdges
            dispatch_array([sketch]),  # SketchFeats: the profile sketch
            options,  # BooleanOptions
            math.radians(angle),  # FlangeAngle
            _m(bend_radius or 0.0),  # FlangeRadius
            _MATERIAL_INSIDE,  # BendPosition
            _m(length),  # FlangeOffsetDist
            _RELIEF_RECTANGULAR,  # ReliefType
            0.5,  # FlangeReliefRatio
            0.0,  # FlangeReliefWidth
            0.0,  # FlangeReliefDepth
            _OUTER_VIRTUAL_SHARP,  # FlangeSharpType
            _null_callout(),  # CustomBendAllowance: the sheet's
        )
        if feature is None:
            raise RuntimeError(
                f"SolidWorks made no edge flange on the edge at "
                f"{list(edge_point)} mm."
            )
        return {
            "name": adapter._attempt(lambda: feature.Name, default=None),
            "edge_length_mm": edge_length,
            "length_mm": float(length),
            "angle_deg": float(angle),
        }

    return cast(
        "AdapterResult[dict[str, Any]]",
        await adapter._measured("add_edge_flange", build),
    )
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]]: name, thickness_mm,

AdapterResult[dict[str, Any]]

bend_radius_mm, k_factor (read back from the feature) and

AdapterResult[dict[str, Any]]

the volume before, after and change.

Source code in src/solidworks_mcp/adapters/solidworks/sheet_metal.py
async def create_base_flange(
    self,
    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``.

    Args:
        thickness: Sheet thickness, mm.
        bend_radius: Inside bend radius, mm.
        k_factor: The bend allowance's K-factor.
        depth: How far an open profile is extruded, mm; not used for a
            closed one.
        sketch: The sketch's name; the last closed sketch when omitted.
        reverse: Thicken to the other side of the sketch.

    Returns:
        AdapterResult[dict[str, Any]]: ``name``, ``thickness_mm``,
        ``bend_radius_mm``, ``k_factor`` (read back from the feature) and
        the volume before, after and change.
    """
    adapter: Any = self
    name = sketch or getattr(adapter, "_last_sketch_name", None)
    if not name:
        return AdapterResult(
            status=AdapterResultStatus.ERROR,
            error="No sketch to make the base flange from; sketch a profile "
            "and close it with exit_sketch first.",
        )

    def build() -> dict[str, Any]:
        model = adapter.currentModel
        closed = self._sketch_is_closed(name)
        if closed is False and depth is None:
            raise InputRefused(
                f"The sketch '{name}' is an open profile, so it needs depth "
                "(how far to extrude it)."
            )
        model.ClearSelection2(True)
        if not _select_named_feature(adapter, name, 0, append=False):
            raise LookupError(f"Couldn't select the sketch '{name}'.")
        manager = sw_type_info.flagged(model.FeatureManager, "IFeatureManager")
        allowance = sw_type_info.flagged(
            manager.CreateCustomBendAllowance(), "ICustomBendAllowance"
        )
        allowance.Type = _K_FACTOR
        allowance.KFactor = float(k_factor)
        feature = manager.InsertSheetMetalBaseFlange2(
            _m(thickness),  # Thickness
            bool(reverse),  # ThickenDir
            _m(bend_radius),  # Radius
            _m(depth or 0.0),  # ExtrudeDist1
            0.0,  # ExtrudeDist2
            False,  # FlipExtruDir
            _BLIND,  # EndCondition1
            _BLIND,  # EndCondition2
            1,  # DirToUse: 0 builds nothing (seen live, SolidWorks 2026)
            allowance,  # PCBA
            False,  # UseDefaultRelief
            0,  # ReliefType
            0.0,  # ReliefWidth
            0.0,  # ReliefDepth
            0.5,  # ReliefRatio
            True,  # UseReliefRatio
            False,  # Merge
            True,  # UseFeatScope
            True,  # UseAutoSelect
        )
        if feature is None:
            raise RuntimeError(
                f"SolidWorks made no base flange from '{name}'; check the "
                "sketch is one profile on a plane."
            )
        return {
            "name": adapter._attempt(lambda: feature.Name, default=None),
            "sketch": name,
            **self._flange_values(feature, thickness, bend_radius, k_factor),
        }

    return cast(
        "AdapterResult[dict[str, Any]]",
        await adapter._measured("create_base_flange", build, first_feature=True),
    )
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]]: name and the bounding box after.

Source code in src/solidworks_mcp/adapters/solidworks/sheet_metal.py
async def create_sketched_bend(
    self,
    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.

    Args:
        angle: The bend angle, degrees.
        bend_radius: Inside bend radius, mm; the sheet's when omitted.
        sketch: The bend line's sketch; the last closed sketch when omitted.
        reverse: Bend the other way.

    Returns:
        AdapterResult[dict[str, Any]]: ``name`` and the bounding box after.
    """
    refusal = self._sheet_metal_refusal("create_sketched_bend")
    if refusal is not None:
        return refusal
    adapter: Any = self
    name = sketch or getattr(adapter, "_last_sketch_name", None)
    if not name:
        return AdapterResult(
            status=AdapterResultStatus.ERROR,
            error="No sketch with a bend line; sketch a line on a face of the "
            "sheet and close it with exit_sketch first.",
        )

    def build() -> dict[str, Any]:
        model = adapter.currentModel
        manager = sw_type_info.flagged(model.FeatureManager, "IFeatureManager")
        data = sw_type_info.flagged(
            manager.CreateDefinition(_SKETCH_BEND), "ISketchedBendFeatureData"
        )
        data.BendAngle = math.radians(angle)
        data.UseDefaultBendRadius = bend_radius is None
        if bend_radius is not None:
            data.BendRadius = _m(bend_radius)
        data.ReverseDirection = bool(reverse)
        model.ClearSelection2(True)
        if not _select_named_feature(adapter, name, 0, append=False):
            raise LookupError(f"Couldn't select the sketch '{name}'.")
        feature = manager.CreateFeature(data)
        if feature is None:
            raise RuntimeError(
                f"SolidWorks made no sketched bend from '{name}'; the sketch "
                "must be a line across a face of the sheet."
            )
        return {
            "name": adapter._attempt(lambda: feature.Name, default=None),
            "sketch": name,
            "angle_deg": float(angle),
        }

    return await self._with_box("create_sketched_bend", build)
set_flat_pattern async
set_flat_pattern(flat: bool) -> AdapterResult[dict[str, Any]]

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]]: flat, feature (the flat

AdapterResult[dict[str, Any]]

pattern's name) and bounding_box_mm in that state (flattened:

AdapterResult[dict[str, Any]]

the blank's size).

Source code in src/solidworks_mcp/adapters/solidworks/sheet_metal.py
async def set_flat_pattern(self, flat: bool) -> AdapterResult[dict[str, Any]]:
    """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).

    Args:
        flat: True to flatten, False to fold.

    Returns:
        AdapterResult[dict[str, Any]]: ``flat``, ``feature`` (the flat
        pattern's name) and ``bounding_box_mm`` in that state (flattened:
        the blank's size).
    """
    refusal = self._sheet_metal_refusal("set_flat_pattern")
    if refusal is not None:
        return refusal
    adapter: Any = self
    found = cast(
        "AdapterResult[str]",
        adapter._handle_com_operation("set_flat_pattern", self._flat_pattern_name),
    )
    if not found.is_success:
        return cast("AdapterResult[dict[str, Any]]", found)
    name = str(found.data)
    changed = await adapter.suppress_feature(name, suppress=not flat)
    if not changed.is_success:
        return cast("AdapterResult[dict[str, Any]]", changed)
    summary = await adapter.get_model_geometry_summary()
    return AdapterResult(
        status=AdapterResultStatus.SUCCESS,
        data={
            "flat": bool(flat),
            "feature": name,
            "bounding_box_mm": (summary.data or {}).get("bounding_box_mm"),
        },
    )

_BodyEntityPicker

_BodyEntityPicker(adapter: Any)

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 currentModel.

required
Source code in src/solidworks_mcp/adapters/solidworks/features.py
def __init__(self, adapter: Any) -> None:
    self._adapter = adapter
    self._cache: dict[str, list[Any]] = {}
Methods:
entities
entities(getter: str) -> list[Any]

Return every solid body's GetEdges() or GetFaces().

Source code in src/solidworks_mcp/adapters/solidworks/features.py
def entities(self, getter: str) -> list[Any]:
    """Return every solid body's ``GetEdges()`` or ``GetFaces()``."""
    if getter not in self._cache:
        model = self._adapter.currentModel
        _flag(self._adapter, model, "GetBodies2")
        bodies = as_list(
            _attempt(self._adapter, lambda: model.GetBodies2(0, False))
        )
        found: list[Any] = []
        for body in bodies:
            _flag(self._adapter, body, getter)
            found.extend(
                as_list(
                    _attempt(self._adapter, lambda b=body: getattr(b, getter)())
                )
            )
        self._cache[getter] = found
    return self._cache[getter]
nearest
nearest(getter: str, point: tuple[float, float, float]) -> tuple[Any, float] | None

Return (entity, distance_m) for the closest entity, or None.

Source code in src/solidworks_mcp/adapters/solidworks/features.py
def nearest(
    self, getter: str, point: tuple[float, float, float]
) -> tuple[Any, float] | None:
    """Return ``(entity, distance_m)`` for the closest entity, or ``None``."""
    best: tuple[Any, float] | None = None
    for entity in self.entities(getter):
        _flag(self._adapter, entity, "GetClosestPointOn")
        closest = _attempt(
            self._adapter, lambda e=entity: list(e.GetClosestPointOn(*point))
        )
        if not closest or len(closest) < 3:
            continue
        distance = math.dist([float(c) for c in closest[:3]], point)
        if best is None or distance < best[1]:
            best = (entity, distance)
    return best
select
select(entity: Any, append: bool, mark: int = 0) -> bool

Select entity with IEntity.Select4 under mark.

Source code in src/solidworks_mcp/adapters/solidworks/features.py
def select(self, entity: Any, append: bool, mark: int = 0) -> bool:
    """Select ``entity`` with ``IEntity.Select4`` under ``mark``."""
    model = self._adapter.currentModel
    sel_mgr = _attempt(self._adapter, lambda: model.SelectionManager)
    _flag(self._adapter, sel_mgr, "CreateSelectData")
    select_data = _attempt(self._adapter, lambda: sel_mgr.CreateSelectData())
    if select_data is None:
        return False
    if mark:
        _attempt(self._adapter, lambda: setattr(select_data, "Mark", mark))
    _flag(self._adapter, entity, "Select4")
    return bool(
        _attempt(self._adapter, lambda: entity.Select4(append, select_data), False)
    )

Functions:

_m

_m(mm: float) -> float

Millimetres to metres.

Source code in src/solidworks_mcp/adapters/solidworks/sheet_metal.py
def _m(mm: float) -> float:
    """Millimetres to metres."""
    return float(mm) / 1000.0

_null_callout

_null_callout() -> Any

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 VARIANT(VT_DISPATCH, None), or a non-None sentinel

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 None).

Source code in src/solidworks_mcp/adapters/solidworks/features.py
def _null_callout() -> Any:
    """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:
        Any: A ``VARIANT(VT_DISPATCH, None)``, or a non-``None`` sentinel
        when pywin32 is unavailable (mock/Linux runs, where no real COM call
        will be made anyway, but the value must still never be bare ``None``).
    """
    try:
        import pythoncom
        import win32com.client as _win32com
    except ImportError:
        return _NULL_CALLOUT_SENTINEL
    return _win32com.VARIANT(pythoncom.VT_DISPATCH, None)

_select_named_feature

_select_named_feature(adapter: Any, name: str, mark: int, append: bool) -> bool

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 currentModel.

required
name str

Feature name (e.g. "Sketch1" or "Helix/Spiral1"). Any @document qualifier is stripped before lookup. A default plane ("Top Plane", "Right"...) or the origin is found by its place in the tree, in any language (#262, fixed in 2.2.0).

required
mark int

Selection mark — 1=profile, 2=guide curve, 4=sweep path.

required
append bool

True to add to the current selection set, False to replace it.

required

Returns:

Name Type Description
bool bool

True when the feature was found and selected.

Source code in src/solidworks_mcp/adapters/solidworks/features.py
def _select_named_feature(
    adapter: Any,
    name: str,
    mark: int,
    append: bool,
) -> bool:
    """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.

    Args:
        adapter: A connected adapter with a valid ``currentModel``.
        name: Feature name (e.g. ``"Sketch1"`` or ``"Helix/Spiral1"``).  Any
            ``@document`` qualifier is stripped before lookup. A default
            plane (``"Top Plane"``, ``"Right"``...) or the origin is found by
            its place in the tree, in any language (#262, fixed in 2.2.0).
        mark: Selection mark — 1=profile, 2=guide curve, 4=sweep path.
        append: ``True`` to add to the current selection set, ``False`` to
            replace it.

    Returns:
        bool: ``True`` when the feature was found and selected.
    """
    bare = entity_name(adapter, name.split("@", 1)[0])
    feature = adapter._attempt(
        lambda: adapter.currentModel.FeatureByName(bare), default=None
    )
    if not feature:
        return False
    return bool(adapter._attempt(lambda: feature.Select2(append, mark), default=False))

as_list

as_list(value: Any) -> list[Any]

Normalise a COM array/scalar/None return into a list.

Source code in src/solidworks_mcp/adapters/solidworks/com_utils.py
def as_list(value: Any) -> list[Any]:
    """Normalise a COM array/scalar/None return into a list."""
    if value is None:
        return []
    if isinstance(value, (list, tuple)):
        return list(value)
    return [value]

dispatch_array

dispatch_array(values: list[Any]) -> Any

VARIANT(VT_ARRAY | VT_DISPATCH), e.g. edges for a flange (tuple when pywin32 is absent).

Source code in src/solidworks_mcp/adapters/solidworks/com_utils.py
def dispatch_array(values: list[Any]) -> Any:
    """``VARIANT(VT_ARRAY | VT_DISPATCH)``, e.g. edges for a flange (tuple when pywin32 is absent)."""
    try:
        import pythoncom
        import win32com.client as w32

        return w32.VARIANT(pythoncom.VT_ARRAY | pythoncom.VT_DISPATCH, list(values))
    except ImportError:  # non-Windows
        return tuple(values)