Skip to content

solidworks_mcp.tools.vba_generation

solidworks_mcp.tools.vba_generation

VBA Code Generation tools for SolidWorks MCP Server.

Provides tools for generating VBA macros for complex SolidWorks operations, especially useful for operations with 13+ parameters that exceed COM limits.

Classes

CompatInput

Bases: BaseModel

Base schema allowing legacy/extra fields used by existing tests.

Attributes:

Name Type Description
model_config Any

The model config value.

SolidWorksAdapter

SolidWorksAdapter(config: object | None = None)

Bases: ABC

Base adapter interface for SolidWorks integration.

Parameters:

Name Type Description Default
config object | None

Configuration values for the operation. Defaults to None.

None

Attributes:

Name Type Description
_metrics Any

The metrics value.

config Any

The config value.

config_dict Any

The config dict value.

Initialize adapter with configuration.

Parameters:

Name Type Description Default
config object | None

Configuration values for the operation. Defaults to None.

None
Source code in src/solidworks_mcp/adapters/base.py
def __init__(self, config: object | None = None):
    """Initialize adapter with configuration.

    Args:
        config (object | None): Configuration values for the operation. Defaults to None.
    """
    if config is None:
        normalized_config: dict[str, Any] = {}
    elif isinstance(config, Mapping):
        normalized_config = dict(config)
    elif hasattr(config, "model_dump"):
        normalized_config = dict(config.model_dump())
    else:
        normalized_config = {}

    # Preserve original config object for compatibility with tests and
    # call sites that compare object identity/equality.
    self.config = config
    # Keep a normalized mapping for adapter internals.
    self.config_dict = normalized_config
    self._metrics = {
        "operations_count": 0,
        "errors_count": 0,
        "average_response_time": 0.0,
    }
Functions
add_arc async
add_arc(center_x: float, center_y: float, start_x: float, start_y: float, end_x: float, end_y: float) -> AdapterResult[str]

Add an arc to the current sketch.

Parameters:

Name Type Description Default
center_x float

The center x value.

required
center_y float

The center y value.

required
start_x float

The start x value.

required
start_y float

The start y value.

required
end_x float

The end x value.

required
end_y float

The end y value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def add_arc(
    self,
    center_x: float,
    center_y: float,
    start_x: float,
    start_y: float,
    end_x: float,
    end_y: float,
) -> AdapterResult[str]:
    """Add an arc to the current sketch.

    Args:
        center_x (float): The center x value.
        center_y (float): The center y value.
        start_x (float): The start x value.
        start_y (float): The start y value.
        end_x (float): The end x value.
        end_y (float): The end y value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_arc is not implemented by this adapter",
    )
add_centerline async
add_centerline(x1: float, y1: float, x2: float, y2: float) -> AdapterResult[str]

Add a centerline to the current sketch.

Parameters:

Name Type Description Default
x1 float

The x1 value.

required
y1 float

The y1 value.

required
x2 float

The x2 value.

required
y2 float

The y2 value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def add_centerline(
    self, x1: float, y1: float, x2: float, y2: float
) -> AdapterResult[str]:
    """Add a centerline to the current sketch.

    Args:
        x1 (float): The x1 value.
        y1 (float): The y1 value.
        x2 (float): The x2 value.
        y2 (float): The y2 value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_centerline is not implemented by this adapter",
    )
add_circle abstractmethod async
add_circle(center_x: float, center_y: float, radius: float) -> AdapterResult[str]

Add a circle to the current sketch.

Parameters:

Name Type Description Default
center_x float

The center x value.

required
center_y float

The center y value.

required
radius float

The radius value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def add_circle(
    self, center_x: float, center_y: float, radius: float
) -> AdapterResult[str]:
    """Add a circle to the current sketch.

    Args:
        center_x (float): The center x value.
        center_y (float): The center y value.
        radius (float): The radius value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    pass
add_ellipse async
add_ellipse(center_x: float, center_y: float, major_axis: float, minor_axis: float) -> AdapterResult[str]

Add an ellipse to the current sketch.

Parameters:

Name Type Description Default
center_x float

The center x value.

required
center_y float

The center y value.

required
major_axis float

The major axis value.

required
minor_axis float

The minor axis value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def add_ellipse(
    self,
    center_x: float,
    center_y: float,
    major_axis: float,
    minor_axis: float,
) -> AdapterResult[str]:
    """Add an ellipse to the current sketch.

    Args:
        center_x (float): The center x value.
        center_y (float): The center y value.
        major_axis (float): The major axis value.
        minor_axis (float): The minor axis value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_ellipse is not implemented by this adapter",
    )
add_fillet async
add_fillet(radius: float, edge_names: list[str]) -> 'AdapterResult[Any]'

Add a fillet feature to selected edges.

Rounds the selected edges of the current solid body with the given radius.

Parameters:

Name Type Description Default
radius float

Fillet radius in millimeters.

required
edge_names list[str]

List of edge names to fillet.

required

Returns:

Name Type Description
AdapterResult 'AdapterResult[Any]'

Feature result or error.

Source code in src/solidworks_mcp/adapters/base.py
async def add_fillet(
    self, radius: float, edge_names: list[str]
) -> "AdapterResult[Any]":
    """Add a fillet feature to selected edges.

    Rounds the selected edges of the current solid body with the given radius.

    Args:
        radius (float): Fillet radius in millimeters.
        edge_names (list[str]): List of edge names to fillet.

    Returns:
        AdapterResult: Feature result or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_fillet is not implemented by this adapter",
    )
add_line abstractmethod async
add_line(x1: float, y1: float, x2: float, y2: float) -> AdapterResult[str]

Add a line to the current sketch.

Parameters:

Name Type Description Default
x1 float

The x1 value.

required
y1 float

The y1 value.

required
x2 float

The x2 value.

required
y2 float

The y2 value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def add_line(
    self, x1: float, y1: float, x2: float, y2: float
) -> AdapterResult[str]:
    """Add a line to the current sketch.

    Args:
        x1 (float): The x1 value.
        y1 (float): The y1 value.
        x2 (float): The x2 value.
        y2 (float): The y2 value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    pass
add_polygon async
add_polygon(center_x: float, center_y: float, radius: float, sides: int) -> AdapterResult[str]

Add a regular polygon to the current sketch.

Parameters:

Name Type Description Default
center_x float

The center x value.

required
center_y float

The center y value.

required
radius float

The radius value.

required
sides int

The sides value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def add_polygon(
    self, center_x: float, center_y: float, radius: float, sides: int
) -> AdapterResult[str]:
    """Add a regular polygon to the current sketch.

    Args:
        center_x (float): The center x value.
        center_y (float): The center y value.
        radius (float): The radius value.
        sides (int): The sides value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_polygon is not implemented by this adapter",
    )
add_rectangle abstractmethod async
add_rectangle(x1: float, y1: float, x2: float, y2: float) -> AdapterResult[str]

Add a rectangle to the current sketch.

Parameters:

Name Type Description Default
x1 float

The x1 value.

required
y1 float

The y1 value.

required
x2 float

The x2 value.

required
y2 float

The y2 value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def add_rectangle(
    self, x1: float, y1: float, x2: float, y2: float
) -> AdapterResult[str]:
    """Add a rectangle to the current sketch.

    Args:
        x1 (float): The x1 value.
        y1 (float): The y1 value.
        x2 (float): The x2 value.
        y2 (float): The y2 value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    pass
add_sketch_circle async
add_sketch_circle(center_x: float, center_y: float, radius: float, construction: bool = False) -> AdapterResult[str]

Alias for add_circle used by some tool flows.

Parameters:

Name Type Description Default
center_x float

The center x value.

required
center_y float

The center y value.

required
radius float

The radius value.

required
construction bool

The construction value. Defaults to False.

False

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def add_sketch_circle(
    self,
    center_x: float,
    center_y: float,
    radius: float,
    construction: bool = False,
) -> AdapterResult[str]:
    """Alias for add_circle used by some tool flows.

    Args:
        center_x (float): The center x value.
        center_y (float): The center y value.
        radius (float): The radius value.
        construction (bool): The construction value. Defaults to False.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return await self.add_circle(center_x, center_y, radius)
add_sketch_constraint async
add_sketch_constraint(entity1: str, entity2: str | None, relation_type: str, entity3: str | None = None) -> AdapterResult[str]

Apply a geometric constraint between sketch entities.

Parameters:

Name Type Description Default
entity1 str

The entity1 value.

required
entity2 str | None

The entity2 value.

required
relation_type str

The relation type value.

required
entity3 str | None

Third entity ID — only used by the symmetric relation (the centerline of symmetry). All other relation types reject a non-null entity3.

None

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def add_sketch_constraint(
    self,
    entity1: str,
    entity2: str | None,
    relation_type: str,
    entity3: str | None = None,
) -> AdapterResult[str]:
    """Apply a geometric constraint between sketch entities.

    Args:
        entity1 (str): The entity1 value.
        entity2 (str | None): The entity2 value.
        relation_type (str): The relation type value.
        entity3 (str | None): Third entity ID — only used by the
            ``symmetric`` relation (the centerline of symmetry). All
            other relation types reject a non-null ``entity3``.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_sketch_constraint is not implemented by this adapter",
    )
add_sketch_dimension async
add_sketch_dimension(entity1: str, entity2: str | None, dimension_type: str, value: float) -> AdapterResult[str]

Add a sketch dimension.

Parameters:

Name Type Description Default
entity1 str

The entity1 value.

required
entity2 str | None

The entity2 value.

required
dimension_type str

The dimension type value.

required
value float

The value value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def add_sketch_dimension(
    self,
    entity1: str,
    entity2: str | None,
    dimension_type: str,
    value: float,
) -> AdapterResult[str]:
    """Add a sketch dimension.

    Args:
        entity1 (str): The entity1 value.
        entity2 (str | None): The entity2 value.
        dimension_type (str): The dimension type value.
        value (float): The value value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_sketch_dimension is not implemented by this adapter",
    )
add_spline async
add_spline(points: list[dict[str, float]]) -> AdapterResult[str]

Add a spline through the provided points.

Parameters:

Name Type Description Default
points list[dict[str, float]]

The points value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def add_spline(self, points: list[dict[str, float]]) -> AdapterResult[str]:
    """Add a spline through the provided points.

    Args:
        points (list[dict[str, float]]): The points value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_spline is not implemented by this adapter",
    )
check_sketch_fully_defined async
check_sketch_fully_defined(sketch_name: str | None = None) -> AdapterResult[dict[str, Any]]

Check whether a sketch is fully defined.

Parameters:

Name Type Description Default
sketch_name str | None

Optional sketch name to inspect. Defaults to None.

None

Returns:

Type Description
AdapterResult[dict[str, Any]]

AdapterResult[dict[str, Any]]: Definition status payload.

Source code in src/solidworks_mcp/adapters/base.py
async def check_sketch_fully_defined(
    self, sketch_name: str | None = None
) -> AdapterResult[dict[str, Any]]:
    """Check whether a sketch is fully defined.

    Args:
        sketch_name (str | None): Optional sketch name to inspect. Defaults to None.

    Returns:
        AdapterResult[dict[str, Any]]: Definition status payload.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="check_sketch_fully_defined is not implemented by this adapter",
    )
close_model abstractmethod async
close_model(save: bool = False) -> AdapterResult[None]

Close the current model.

Parameters:

Name Type Description Default
save bool

The save value. Defaults to False.

False

Returns:

Type Description
AdapterResult[None]

AdapterResult[None]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def close_model(self, save: bool = False) -> AdapterResult[None]:
    """Close the current model.

    Args:
        save (bool): The save value. Defaults to False.

    Returns:
        AdapterResult[None]: The result produced by the operation.
    """
    pass
connect abstractmethod async
connect() -> None

Connect to SolidWorks application.

Returns:

Name Type Description
None None

None.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def connect(self) -> None:
    """Connect to SolidWorks application.

    Returns:
        None: None.
    """
    pass
create_assembly abstractmethod async
create_assembly(name: str | None = None) -> AdapterResult[SolidWorksModel]

Create a new assembly document.

Parameters:

Name Type Description Default
name str | None

The name value. Defaults to None.

None

Returns:

Type Description
AdapterResult[SolidWorksModel]

AdapterResult[SolidWorksModel]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def create_assembly(
    self, name: str | None = None
) -> AdapterResult[SolidWorksModel]:
    """Create a new assembly document.

    Args:
        name (str | None): The name value. Defaults to None.

    Returns:
        AdapterResult[SolidWorksModel]: The result produced by the operation.
    """
    pass
create_cut async
create_cut(sketch_name: str, depth: float) -> AdapterResult[str]

Create a cut feature from an existing sketch.

Parameters:

Name Type Description Default
sketch_name str

The sketch name value.

required
depth float

The depth value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def create_cut(self, sketch_name: str, depth: float) -> AdapterResult[str]:
    """Create a cut feature from an existing sketch.

    Args:
        sketch_name (str): The sketch name value.
        depth (float): The depth value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="create_cut is not implemented by this adapter",
    )
create_cut_extrude async
create_cut_extrude(params: 'ExtrusionParameters') -> 'AdapterResult[Any]'

Create a cut-extrude feature from the active sketch.

Cuts material from the current solid body using the active sketch profile. Equivalent to SolidWorks Insert > Cut > Extrude.

Parameters:

Name Type Description Default
params ExtrusionParameters

Depth and direction parameters.

required

Returns:

Name Type Description
AdapterResult 'AdapterResult[Any]'

Feature result or error.

Source code in src/solidworks_mcp/adapters/base.py
async def create_cut_extrude(
    self, params: "ExtrusionParameters"
) -> "AdapterResult[Any]":
    """Create a cut-extrude feature from the active sketch.

    Cuts material from the current solid body using the active sketch profile.
    Equivalent to SolidWorks Insert > Cut > Extrude.

    Args:
        params (ExtrusionParameters): Depth and direction parameters.

    Returns:
        AdapterResult: Feature result or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="create_cut_extrude is not implemented by this adapter",
    )
create_drawing abstractmethod async
create_drawing(name: str | None = None) -> AdapterResult[SolidWorksModel]

Create a new drawing document.

Parameters:

Name Type Description Default
name str | None

The name value. Defaults to None.

None

Returns:

Type Description
AdapterResult[SolidWorksModel]

AdapterResult[SolidWorksModel]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def create_drawing(
    self, name: str | None = None
) -> AdapterResult[SolidWorksModel]:
    """Create a new drawing document.

    Args:
        name (str | None): The name value. Defaults to None.

    Returns:
        AdapterResult[SolidWorksModel]: The result produced by the operation.
    """
    pass
create_extrusion abstractmethod async
create_extrusion(params: ExtrusionParameters) -> AdapterResult[SolidWorksFeature]

Create an extrusion feature.

Parameters:

Name Type Description Default
params ExtrusionParameters

The params value.

required

Returns:

Type Description
AdapterResult[SolidWorksFeature]

AdapterResult[SolidWorksFeature]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def create_extrusion(
    self, params: ExtrusionParameters
) -> AdapterResult[SolidWorksFeature]:
    """Create an extrusion feature.

    Args:
        params (ExtrusionParameters): The params value.

    Returns:
        AdapterResult[SolidWorksFeature]: The result produced by the operation.
    """
    pass
create_loft abstractmethod async
create_loft(params: LoftParameters) -> AdapterResult[SolidWorksFeature]

Create a loft feature.

Parameters:

Name Type Description Default
params LoftParameters

The params value.

required

Returns:

Type Description
AdapterResult[SolidWorksFeature]

AdapterResult[SolidWorksFeature]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def create_loft(
    self, params: LoftParameters
) -> AdapterResult[SolidWorksFeature]:
    """Create a loft feature.

    Args:
        params (LoftParameters): The params value.

    Returns:
        AdapterResult[SolidWorksFeature]: The result produced by the operation.
    """
    pass
create_part abstractmethod async
create_part(name: str | None = None, units: str | None = None) -> AdapterResult[SolidWorksModel]

Create a new part document.

Parameters:

Name Type Description Default
name str | None

The name value. Defaults to None.

None
units str | None

The units value. Defaults to None.

None

Returns:

Type Description
AdapterResult[SolidWorksModel]

AdapterResult[SolidWorksModel]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def create_part(
    self, name: str | None = None, units: str | None = None
) -> AdapterResult[SolidWorksModel]:
    """Create a new part document.

    Args:
        name (str | None): The name value. Defaults to None.
        units (str | None): The units value. Defaults to None.

    Returns:
        AdapterResult[SolidWorksModel]: The result produced by the operation.
    """
    pass
create_revolve abstractmethod async
create_revolve(params: RevolveParameters) -> AdapterResult[SolidWorksFeature]

Create a revolve feature.

Parameters:

Name Type Description Default
params RevolveParameters

The params value.

required

Returns:

Type Description
AdapterResult[SolidWorksFeature]

AdapterResult[SolidWorksFeature]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def create_revolve(
    self, params: RevolveParameters
) -> AdapterResult[SolidWorksFeature]:
    """Create a revolve feature.

    Args:
        params (RevolveParameters): The params value.

    Returns:
        AdapterResult[SolidWorksFeature]: The result produced by the operation.
    """
    pass
create_sketch abstractmethod async
create_sketch(plane: str) -> AdapterResult[str]

Create a new sketch on the specified plane.

Parameters:

Name Type Description Default
plane str

The plane value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def create_sketch(self, plane: str) -> AdapterResult[str]:
    """Create a new sketch on the specified plane.

    Args:
        plane (str): The plane value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    pass
create_sweep abstractmethod async
create_sweep(params: SweepParameters) -> AdapterResult[SolidWorksFeature]

Create a sweep feature.

Parameters:

Name Type Description Default
params SweepParameters

The params value.

required

Returns:

Type Description
AdapterResult[SolidWorksFeature]

AdapterResult[SolidWorksFeature]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def create_sweep(
    self, params: SweepParameters
) -> AdapterResult[SolidWorksFeature]:
    """Create a sweep feature.

    Args:
        params (SweepParameters): The params value.

    Returns:
        AdapterResult[SolidWorksFeature]: The result produced by the operation.
    """
    pass
disconnect abstractmethod async
disconnect() -> None

Disconnect from SolidWorks application.

Returns:

Name Type Description
None None

None.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def disconnect(self) -> None:
    """Disconnect from SolidWorks application.

    Returns:
        None: None.
    """
    pass
exit_sketch abstractmethod async
exit_sketch() -> AdapterResult[None]

Exit sketch editing mode.

Returns:

Type Description
AdapterResult[None]

AdapterResult[None]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def exit_sketch(self) -> AdapterResult[None]:
    """Exit sketch editing mode.

    Returns:
        AdapterResult[None]: The result produced by the operation.
    """
    pass
export_file abstractmethod async
export_file(file_path: str, format_type: str) -> AdapterResult[None]

Export the current model to a file.

Parameters:

Name Type Description Default
file_path str

Path to the target file.

required
format_type str

The format type value.

required

Returns:

Type Description
AdapterResult[None]

AdapterResult[None]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def export_file(
    self, file_path: str, format_type: str
) -> AdapterResult[None]:
    """Export the current model to a file.

    Args:
        file_path (str): Path to the target file.
        format_type (str): The format type value.

    Returns:
        AdapterResult[None]: The result produced by the operation.
    """
    pass
export_image abstractmethod async
export_image(payload: dict) -> AdapterResult[dict]

Export a viewport screenshot (PNG/JPG) of the current model.

Payload keys: file_path (str): Absolute output path. width (int): Image width in pixels. height (int): Image height in pixels. view_orientation (str): One of "isometric", "front", "top", "right", "back", "bottom", "current".

Parameters:

Name Type Description Default
payload dict

The payload value.

required

Returns:

Type Description
AdapterResult[dict]

AdapterResult[dict]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def export_image(self, payload: dict) -> AdapterResult[dict]:
    """Export a viewport screenshot (PNG/JPG) of the current model.

    Payload keys: file_path (str): Absolute output path. width (int): Image width in pixels.
    height (int): Image height in pixels. view_orientation (str): One of "isometric",
    "front", "top", "right", "back", "bottom", "current".

    Args:
        payload (dict): The payload value.

    Returns:
        AdapterResult[dict]: The result produced by the operation.
    """
    pass
get_dimension abstractmethod async
get_dimension(name: str) -> AdapterResult[float]

Get the value of a dimension.

Parameters:

Name Type Description Default
name str

The name value.

required

Returns:

Type Description
AdapterResult[float]

AdapterResult[float]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def get_dimension(self, name: str) -> AdapterResult[float]:
    """Get the value of a dimension.

    Args:
        name (str): The name value.

    Returns:
        AdapterResult[float]: The result produced by the operation.
    """
    pass
get_mass_properties abstractmethod async
get_mass_properties() -> AdapterResult[MassProperties]

Get mass properties of the current model.

Returns:

Type Description
AdapterResult[MassProperties]

AdapterResult[MassProperties]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def get_mass_properties(self) -> AdapterResult[MassProperties]:
    """Get mass properties of the current model.

    Returns:
        AdapterResult[MassProperties]: The result produced by the operation.
    """
    pass
get_metrics
get_metrics() -> dict[str, Any]

Get adapter metrics.

Returns:

Type Description
dict[str, Any]

dict[str, Any]: A dictionary containing the resulting values.

Source code in src/solidworks_mcp/adapters/base.py
def get_metrics(self) -> dict[str, Any]:
    """Get adapter metrics.

    Returns:
        dict[str, Any]: A dictionary containing the resulting values.
    """
    return self._metrics.copy()
get_model_info abstractmethod async
get_model_info() -> AdapterResult[dict[str, Any]]

Get metadata for the active model.

Returns:

Type Description
AdapterResult[dict[str, Any]]

AdapterResult[dict[str, Any]]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def get_model_info(self) -> AdapterResult[dict[str, Any]]:
    """Get metadata for the active model.

    Returns:
        AdapterResult[dict[str, Any]]: The result produced by the operation.
    """
    pass
health_check abstractmethod async
health_check() -> AdapterHealth

Get adapter health status.

Returns:

Name Type Description
AdapterHealth AdapterHealth

The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def health_check(self) -> AdapterHealth:
    """Get adapter health status.

    Returns:
        AdapterHealth: The result produced by the operation.
    """
    pass
is_connected abstractmethod
is_connected() -> bool

Check if connected to SolidWorks.

Returns:

Name Type Description
bool bool

True if connected, otherwise False.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
def is_connected(self) -> bool:
    """Check if connected to SolidWorks.

    Returns:
        bool: True if connected, otherwise False.
    """
    pass
list_configurations abstractmethod async
list_configurations() -> AdapterResult[list[str]]

List configuration names for the active model.

Returns:

Type Description
AdapterResult[list[str]]

AdapterResult[list[str]]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def list_configurations(self) -> AdapterResult[list[str]]:
    """List configuration names for the active model.

    Returns:
        AdapterResult[list[str]]: The result produced by the operation.
    """
    pass
list_features abstractmethod async
list_features(include_suppressed: bool = False) -> AdapterResult[list[dict[str, Any]]]

List model features from the feature tree.

Parameters:

Name Type Description Default
include_suppressed bool

The include suppressed value. Defaults to False.

False

Returns:

Type Description
AdapterResult[list[dict[str, Any]]]

AdapterResult[list[dict[str, Any]]]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def list_features(
    self, include_suppressed: bool = False
) -> AdapterResult[list[dict[str, Any]]]:
    """List model features from the feature tree.

    Args:
        include_suppressed (bool): The include suppressed value. Defaults to False.

    Returns:
        AdapterResult[list[dict[str, Any]]]: The result produced by the operation.
    """
    pass
open_model abstractmethod async
open_model(file_path: str) -> AdapterResult[SolidWorksModel]

Open a SolidWorks model (part, assembly, or drawing).

Parameters:

Name Type Description Default
file_path str

Path to the target file.

required

Returns:

Type Description
AdapterResult[SolidWorksModel]

AdapterResult[SolidWorksModel]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def open_model(self, file_path: str) -> AdapterResult[SolidWorksModel]:
    """Open a SolidWorks model (part, assembly, or drawing).

    Args:
        file_path (str): Path to the target file.

    Returns:
        AdapterResult[SolidWorksModel]: The result produced by the operation.
    """
    pass
save_file async
save_file(file_path: str | None = None) -> AdapterResult[Any]

Save the active model to the existing path or the provided path.

Parameters:

Name Type Description Default
file_path str | None

Path to the target file. Defaults to None.

None

Returns:

Type Description
AdapterResult[Any]

AdapterResult[Any]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def save_file(self, file_path: str | None = None) -> AdapterResult[Any]:
    """Save the active model to the existing path or the provided path.

    Args:
        file_path (str | None): Path to the target file. Defaults to None.

    Returns:
        AdapterResult[Any]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="save_file is not implemented by this adapter",
    )
set_dimension abstractmethod async
set_dimension(name: str, value: float) -> AdapterResult[None]

Set the value of a dimension.

Parameters:

Name Type Description Default
name str

The name value.

required
value float

The value value.

required

Returns:

Type Description
AdapterResult[None]

AdapterResult[None]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def set_dimension(self, name: str, value: float) -> AdapterResult[None]:
    """Set the value of a dimension.

    Args:
        name (str): The name value.
        value (float): The value value.

    Returns:
        AdapterResult[None]: The result produced by the operation.
    """
    pass
sketch_circular_pattern async
sketch_circular_pattern(entities: list[str], angle: float, count: int) -> AdapterResult[str]

Create a circular pattern of sketch entities around the sketch origin.

The rotation axis is always the sketch origin — SW's CreateCircularSketchStepAndRepeat has no pattern-centre parameter and derives the axis from the seed's geometry. Place the seed entity at the desired radius from the origin.

Parameters:

Name Type Description Default
entities list[str]

The entities value.

required
angle float

The angle value.

required
count int

The count value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def sketch_circular_pattern(
    self,
    entities: list[str],
    angle: float,
    count: int,
) -> AdapterResult[str]:
    """Create a circular pattern of sketch entities around the sketch origin.

    The rotation axis is always the sketch origin — SW's
    ``CreateCircularSketchStepAndRepeat`` has no pattern-centre
    parameter and derives the axis from the seed's geometry. Place
    the seed entity at the desired radius from the origin.

    Args:
        entities (list[str]): The entities value.
        angle (float): The angle value.
        count (int): The count value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="sketch_circular_pattern is not implemented by this adapter",
    )
sketch_linear_pattern async
sketch_linear_pattern(entities: list[str], direction_x: float, direction_y: float, spacing: float, count: int) -> AdapterResult[str]

Create a linear pattern of sketch entities.

Parameters:

Name Type Description Default
entities list[str]

The entities value.

required
direction_x float

The direction x value.

required
direction_y float

The direction y value.

required
spacing float

The spacing value.

required
count int

The count value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def sketch_linear_pattern(
    self,
    entities: list[str],
    direction_x: float,
    direction_y: float,
    spacing: float,
    count: int,
) -> AdapterResult[str]:
    """Create a linear pattern of sketch entities.

    Args:
        entities (list[str]): The entities value.
        direction_x (float): The direction x value.
        direction_y (float): The direction y value.
        spacing (float): The spacing value.
        count (int): The count value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="sketch_linear_pattern is not implemented by this adapter",
    )
sketch_mirror async
sketch_mirror(entities: list[str], mirror_line: str) -> AdapterResult[str]

Mirror sketch entities about a mirror line.

Parameters:

Name Type Description Default
entities list[str]

The entities value.

required
mirror_line str

The mirror line value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def sketch_mirror(
    self, entities: list[str], mirror_line: str
) -> AdapterResult[str]:
    """Mirror sketch entities about a mirror line.

    Args:
        entities (list[str]): The entities value.
        mirror_line (str): The mirror line value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="sketch_mirror is not implemented by this adapter",
    )
sketch_offset async
sketch_offset(entities: list[str], offset_distance: float, reverse_direction: bool) -> AdapterResult[str]

Offset sketch entities.

Parameters:

Name Type Description Default
entities list[str]

The entities value.

required
offset_distance float

The offset distance value.

required
reverse_direction bool

The reverse direction value.

required

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def sketch_offset(
    self,
    entities: list[str],
    offset_distance: float,
    reverse_direction: bool,
) -> AdapterResult[str]:
    """Offset sketch entities.

    Args:
        entities (list[str]): The entities value.
        offset_distance (float): The offset distance value.
        reverse_direction (bool): The reverse direction value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="sketch_offset is not implemented by this adapter",
    )
update_metrics
update_metrics(operation_time: float, success: bool) -> None

Update adapter metrics.

Parameters:

Name Type Description Default
operation_time float

The operation time value.

required
success bool

The success value.

required

Returns:

Name Type Description
None None

None.

Source code in src/solidworks_mcp/adapters/base.py
def update_metrics(self, operation_time: float, success: bool) -> None:
    """Update adapter metrics.

    Args:
        operation_time (float): The operation time value.
        success (bool): The success value.

    Returns:
        None: None.
    """
    self._metrics["operations_count"] += 1
    if not success:
        self._metrics["errors_count"] += 1

    # Update average response time
    current_avg = self._metrics["average_response_time"]
    count = self._metrics["operations_count"]
    self._metrics["average_response_time"] = (
        current_avg * (count - 1) + operation_time
    ) / count

VBAAssemblyInput

Bases: CompatInput

Input schema for generating VBA assembly operations.

Attributes:

Name Type Description
assembly_file str | None

The assembly file value.

component_file str | None

The component file value.

component_path str | None

The component path value.

insertion_point list[float]

The insertion point value.

operation_type str | None

The operation type value.

rotation list[float]

The rotation value.

VBABatchInput

Bases: CompatInput

Input schema for generating VBA batch operations.

Attributes:

Name Type Description
exclude_list list[str] | None

The exclude list value.

export_format str | None

The export format value.

file_pattern str | None

The file pattern value.

operation_type str | None

The operation type value.

recursive bool

The recursive value.

source_directory str | None

The source directory value.

source_folder str | None

The source folder value.

target_folder str | None

The target folder value.

VBADrawingInput

Bases: CompatInput

Input schema for generating VBA drawing operations.

Attributes:

Name Type Description
advanced_options dict[str, Any] | None

The advanced options value.

drawing_file str | None

The drawing file value.

model_path str | None

The model path value.

operation_type str | None

The operation type value.

scale float

The scale value.

sheet_format str

The sheet format value.

view_layout str | None

The view layout value.

view_scale str | None

The view scale value.

VBAExtrusionInput

Bases: CompatInput

Input schema for generating VBA extrusion code.

Attributes:

Name Type Description
advanced_options dict[str, Any] | None

The advanced options value.

assembly_feature_scope str | None

The assembly feature scope value.

auto_select bool

The auto select value.

both_directions bool

The both directions value.

cap_ends bool

The cap ends value.

cap_thickness float

The cap thickness value.

custom_properties dict[str, Any] | None

The custom properties value.

depth float

The depth value.

depth2 float

The depth2 value.

direction str | None

The direction value.

draft_angle float

The draft angle value.

draft_outward bool

The draft outward value.

end_condition str | None

The end condition value.

end_condition_reference str | None

The end condition reference value.

feature_scope str | bool

The feature scope value.

merge_result bool

The merge result value.

offset_parameters dict[str, Any] | None

The offset parameters value.

sketch_name str | None

The sketch name value.

start_condition str | None

The start condition value.

thin_feature bool

The thin feature value.

thin_thickness float

The thin thickness value.

thin_thickness1 float | None

The thin thickness1 value.

thin_thickness2 float | None

The thin thickness2 value.

thin_type str

The thin type value.

VBARevolveInput

Bases: CompatInput

Input schema for generating VBA revolve code.

Attributes:

Name Type Description
angle float | None

The angle value.

angle2 float

The angle2 value.

angle_degrees float | None

The angle degrees value.

axis_reference str | None

The axis reference value.

both_directions bool

The both directions value.

merge_result bool

The merge result value.

sketch_name str | None

The sketch name value.

thin_feature bool

The thin feature value.

thin_thickness float

The thin thickness value.

Functions
model_post_init
model_post_init(__context: Any) -> None

Provide model post init support for the vbarevolve input.

Parameters:

Name Type Description Default
__context Any

The context value.

required

Returns:

Name Type Description
None None

None.

Source code in src/solidworks_mcp/tools/vba_generation.py
def model_post_init(self, __context: Any) -> None:
    """Provide model post init support for the vbarevolve input.

    Args:
        __context (Any): The context value.

    Returns:
        None: None.
    """
    if self.angle is None:
        self.angle = self.angle_degrees if self.angle_degrees is not None else 360.0

Functions

register_vba_generation_tools async

register_vba_generation_tools(mcp: FastMCP, adapter: SolidWorksAdapter, config: Any) -> int

Register VBA generation tools with FastMCP.

Parameters:

Name Type Description Default
mcp FastMCP

The mcp value.

required
adapter SolidWorksAdapter

Adapter instance used for the operation.

required
config Any

Configuration values for the operation.

required

Returns:

Name Type Description
int int

The computed numeric result.

Example

tool_count = await register_vba_generation_tools(mcp, adapter, config)

Source code in src/solidworks_mcp/tools/vba_generation.py
 222
 223
 224
 225
 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
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 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
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 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
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
async def register_vba_generation_tools(
    mcp: FastMCP, adapter: SolidWorksAdapter, config: Any
) -> int:
    """Register VBA generation tools with FastMCP.

    Args:
        mcp (FastMCP): The mcp value.
        adapter (SolidWorksAdapter): Adapter instance used for the operation.
        config (Any): Configuration values for the operation.

    Returns:
        int: The computed numeric result.

    Example:
                        >>> tool_count = await register_vba_generation_tools(mcp, adapter, config)
    """
    tool_count = 0

    @mcp.tool()
    async def generate_vba_extrusion(input_data: VBAExtrusionInput) -> dict[str, Any]:
        """Generate VBA code for complex extrusion operations.

        Args:
            input_data (VBAExtrusionInput): The input data value.

        Returns:
            dict[str, Any]: A dictionary containing the resulting values.

        Example:
                            >>> result = await generate_vba_extrusion(extrusion_input)
        """
        try:
            if hasattr(adapter, "generate_vba_extrusion"):
                result = await adapter.generate_vba_extrusion(input_data.model_dump())
                if result.is_success:
                    return {
                        "status": "success",
                        "message": "Generated VBA code for advanced extrusion",
                        "data": result.data,
                        "execution_time": result.execution_time,
                    }
                return {
                    "status": "error",
                    "message": result.error or "Failed to generate VBA code",
                }

            vba_code = f"""Sub CreateAdvancedExtrusion()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swFeatMgr As SldWorks.FeatureManager
    Dim swFeat As SldWorks.Feature
    Dim myFeature As Object

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    If swModel Is Nothing Then
        MsgBox "No active document"
        Exit Sub
    End If

    Set swFeatMgr = swModel.FeatureManager

    ' Advanced extrusion with full parameter control
    myFeature = swFeatMgr.FeatureExtruThin2( _
        {input_data.depth / 1000.0}, _  ' Depth (meters)
        {input_data.depth2 / 1000.0}, _ ' Depth2 (meters)
        {str(input_data.both_directions).lower()}, _ ' BothDirections
        {input_data.draft_angle * 3.14159 / 180.0}, _ ' DraftAngle (radians)
        {0}, _ ' DraftAngle2
        {str(input_data.draft_outward).lower()}, _ ' DraftOutward
        {str(input_data.draft_outward).lower()}, _ ' DraftOutward2
        {str(input_data.merge_result).lower()}, _ ' MergeResult
        {str(input_data.feature_scope).lower()}, _ ' FeatureScope
        {str(input_data.auto_select).lower()}, _ ' AutoSelect
        {input_data.thin_thickness / 1000.0}, _ ' Thickness (meters)
        {input_data.thin_thickness / 1000.0}, _ ' Thickness2
        False, _ ' ReverseOffset
        {str(input_data.both_directions).lower()}, _ ' BothDirectionThin
        {str(input_data.cap_ends).lower()}, _ ' CapEnds
        0, _ ' EndCondition
        0 _ ' EndCondition2
    )

    If myFeature Is Nothing Then
        MsgBox "Failed to create extrusion"
    Else
        MsgBox "Advanced extrusion created successfully"
    End If

End Sub"""

            return {
                "status": "success",
                "message": "Generated VBA code for advanced extrusion",
                "vba_code": vba_code,
                "parameters": {
                    "depth": input_data.depth,
                    "both_directions": input_data.both_directions,
                    "thin_feature": input_data.thin_feature,
                    "parameter_count": 17,
                    "complexity": "complex",
                },
                "usage_instructions": [
                    "1. Open SolidWorks VBA editor (Tools > Macro > Edit)",
                    "2. Create new module and paste the generated code",
                    "3. Ensure you have an active sketch selected",
                    "4. Run the macro (F5)",
                ],
            }

        except Exception as e:
            logger.error(f"Error in generate_vba_extrusion tool: {e}")
            return {
                "status": "error",
                "message": f"Failed to generate VBA code: {str(e)}",
            }

    @mcp.tool()
    async def generate_vba_revolve(input_data: VBARevolveInput) -> dict[str, Any]:
        """Generate VBA code for complex revolve operations.

        Args:
            input_data (VBARevolveInput): The input data value.

        Returns:
            dict[str, Any]: A dictionary containing the resulting values.

        Example:
                            >>> result = await generate_vba_revolve(revolve_input)
        """
        """
        Generate VBA code for complex revolve operations.

        Creates VBA macro for revolve features with advanced thin-wall options.
        """
        try:
            if hasattr(adapter, "generate_vba_revolve"):
                result = await adapter.generate_vba_revolve(input_data.model_dump())
                if result.is_success:
                    return {
                        "status": "success",
                        "message": "Generated VBA code for advanced revolve",
                        "data": result.data,
                        "execution_time": result.execution_time,
                    }
                return {
                    "status": "error",
                    "message": result.error or "Failed to generate VBA code",
                }

            vba_code = f"""Sub CreateAdvancedRevolve()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swFeatMgr As SldWorks.FeatureManager
    Dim myFeature As Object

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swFeatMgr = swModel.FeatureManager

    ' Advanced revolve with thin-wall options
    myFeature = swFeatMgr.FeatureRevolve2( _
        True, _ ' SingleDir
        {str(input_data.both_directions).lower()}, _ ' IsSolid
        False, _ ' IsThin
        False, _ ' ReverseDir
        3, _ ' Type (swEndCondBlind)
        3, _ ' Type2
        {(input_data.angle or 0.0) * 3.14159 / 180.0}, _ ' Angle (radians)
        {(input_data.angle2 or 0.0) * 3.14159 / 180.0}, _ ' Angle2
        {str(input_data.merge_result).lower()}, _ ' MergeResult
        False, _ ' FeatureScope
        False, _ ' Auto
        True, _ ' AssemblyFeatureScope
        0, _ ' AutoSelectComponents
        False, _ ' PropagateFeatureToParts
        True, _ ' CreateSelectionSet
        False, _ ' CurveToOrderUse
        False _ ' UseMachinedSurface
    )

    If myFeature Is Nothing Then
        MsgBox "Failed to create revolve"
    Else
        MsgBox "Advanced revolve created successfully"
    End If

End Sub"""

            return {
                "status": "success",
                "message": "Generated VBA code for advanced revolve",
                "vba_code": vba_code,
                "parameters": {
                    "angle": input_data.angle,
                    "both_directions": input_data.both_directions,
                    "thin_feature": input_data.thin_feature,
                    "parameter_count": 16,
                    "complexity": "complex",
                },
                "usage_instructions": [
                    "1. Create a sketch profile and axis of revolution",
                    "2. Select the sketch and axis",
                    "3. Run the generated VBA macro",
                    "4. Check the revolve feature in the feature tree",
                ],
            }

        except Exception as e:
            logger.error(f"Error in generate_vba_revolve tool: {e}")
            return {
                "status": "error",
                "message": f"Failed to generate VBA code: {str(e)}",
            }

    @mcp.tool()
    async def generate_vba_assembly_insert(
        input_data: VBAAssemblyInput,
    ) -> dict[str, Any]:
        """Generate VBA code for assembly component insertion.

        Args:
            input_data (VBAAssemblyInput): The input data value.

        Returns:
            dict[str, Any]: A dictionary containing the resulting values.

        Example:
                            >>> result = await generate_vba_assembly_insert(assembly_input)

                        Generate VBA code for inserting components into assemblies.

                        Creates macro for component insertion with precise positioning.
        """
        try:
            if hasattr(adapter, "generate_vba_assembly_insert"):
                result = await adapter.generate_vba_assembly_insert(
                    input_data.model_dump()
                )
                if result.is_success:
                    return {
                        "status": "success",
                        "message": "Generated VBA code for component insertion",
                        "data": result.data,
                        "execution_time": result.execution_time,
                    }
                return {
                    "status": "error",
                    "message": result.error or "Failed to generate VBA code",
                }

            vba_code = f'''Sub InsertComponent()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swAssy As SldWorks.AssemblyDoc
    Dim swComp As SldWorks.Component2

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swAssy = swModel

    ' Insert component at specified location
    Set swComp = swAssy.AddComponent5( _
        "{input_data.component_path}", _
        0, _ ' Configuration
        "", _ ' Config name
        False, _ ' LoadModel
        "", _ ' ReferenceName
        {input_data.insertion_point[0] / 1000.0}, _ ' X position (meters)
        {input_data.insertion_point[1] / 1000.0}, _ ' Y position (meters)
        {input_data.insertion_point[2] / 1000.0} _ ' Z position (meters)
    )

    If swComp Is Nothing Then
        MsgBox "Failed to insert component"
    Else
        MsgBox "Component inserted successfully: " & swComp.Name2
    End If

End Sub'''

            return {
                "status": "success",
                "message": "Generated VBA code for component insertion",
                "vba_code": vba_code,
                "parameters": {
                    "component_path": input_data.component_path,
                    "insertion_point": input_data.insertion_point,
                    "operation_type": input_data.operation_type,
                },
                "usage_instructions": [
                    "1. Open the target assembly document",
                    "2. Ensure the component file path exists",
                    "3. Run the macro to insert the component",
                    "4. Add mates as needed for positioning",
                ],
            }

        except Exception as e:
            logger.error(f"Error in generate_vba_assembly_insert tool: {e}")
            return {
                "status": "error",
                "message": f"Failed to generate VBA code: {str(e)}",
            }

    @mcp.tool()
    async def generate_vba_drawing_views(input_data: VBADrawingInput) -> dict[str, Any]:
        """Generate VBA code for drawing view creation.

        Args:
            input_data (VBADrawingInput): The input data value.

        Returns:
            dict[str, Any]: A dictionary containing the resulting values.

        Example:
                            >>> result = await generate_vba_drawing_views(drawing_input)
        """
        """
        Generate VBA code for creating drawing views.

        Creates macro for standard drawing view setup.
        """
        try:
            if hasattr(adapter, "generate_vba_drawing_views"):
                result = await adapter.generate_vba_drawing_views(
                    input_data.model_dump()
                )
                if result.is_success:
                    return {
                        "status": "success",
                        "message": "Generated VBA code for drawing views",
                        "data": result.data,
                        "execution_time": result.execution_time,
                    }
                return {
                    "status": "error",
                    "message": result.error or "Failed to generate VBA code",
                }

            vba_code = f'''Sub CreateDrawingViews()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swDraw As SldWorks.DrawingDoc
    Dim swView As SldWorks.View
    Dim swSheet As SldWorks.Sheet

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel

    If swDraw Is Nothing Then
        MsgBox "No active drawing document"
        Exit Sub
    End If

    Set swSheet = swDraw.GetCurrentSheet

    ' Create standard 3 view drawing
    ' Front view
    Set swView = swDraw.CreateDrawViewFromModelView3( _
        "{input_data.model_path}", _
        "*Front", _
        0.1, _ ' X position
        0.15, _ ' Y position
        0 _ ' Z position
    )

    swView.ScaleRatio = Array({input_data.scale}, 1)

    ' Top view
    Set swView = swDraw.CreateDrawViewFromModelView3( _
        "{input_data.model_path}", _
        "*Top", _
        0.1, _
        0.25, _
        0 _
    )

    swView.ScaleRatio = Array({input_data.scale}, 1)

    ' Right view
    Set swView = swDraw.CreateDrawViewFromModelView3( _
        "{input_data.model_path}", _
        "*Right", _
        0.25, _
        0.15, _
        0 _
    )

    swView.ScaleRatio = Array({input_data.scale}, 1)

    MsgBox "Drawing views created successfully"

End Sub'''

            return {
                "status": "success",
                "message": "Generated VBA code for drawing views",
                "vba_code": vba_code,
                "parameters": {
                    "model_path": input_data.model_path,
                    "scale": input_data.scale,
                    "sheet_format": input_data.sheet_format,
                },
                "usage_instructions": [
                    "1. Create a new drawing document",
                    "2. Verify the 3D model path is correct",
                    "3. Run the macro to create standard views",
                    "4. Adjust view positions as needed",
                ],
            }

        except Exception as e:
            logger.error(f"Error in generate_vba_drawing_views tool: {e}")
            return {
                "status": "error",
                "message": f"Failed to generate VBA code: {str(e)}",
            }

    @mcp.tool()
    async def generate_vba_batch_export(input_data: VBABatchInput) -> dict[str, Any]:
        """Generate VBA code for batch file export operations.

        Args:
            input_data (VBABatchInput): The input data value.

        Returns:
            dict[str, Any]: A dictionary containing the resulting values.

        Example:
                            >>> result = await generate_vba_batch_export(batch_input)
        """
        """
        Generate VBA code for batch file operations.

        Creates macro for processing multiple files automatically.
        """
        try:
            if hasattr(adapter, "generate_vba_batch_export"):
                result = await adapter.generate_vba_batch_export(
                    input_data.model_dump()
                )
                if result.is_success:
                    return {
                        "status": "success",
                        "message": f"Generated VBA code for batch {input_data.operation_type}",
                        "data": result.data,
                        "execution_time": result.execution_time,
                    }
                return {
                    "status": "error",
                    "message": result.error or "Failed to generate VBA code",
                }

            vba_code = f'''Sub BatchExport()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim fso As FileSystemObject
    Dim folder As Folder
    Dim file As file
    Dim filePath As String
    Dim exportPath As String
    Dim processedCount As Integer

    Set swApp = Application.SldWorks
    Set fso = New FileSystemObject
    Set folder = fso.GetFolder("{input_data.source_folder}")

    processedCount = 0

    ' Process all files matching pattern
    For Each file In folder.Files
        If LCase(file.Name) Like LCase("{input_data.file_pattern}") Then
            filePath = file.Path

            ' Open the file
            Set swModel = swApp.OpenDoc6(filePath, 1, 1, "", 0, 0)

            If Not swModel Is Nothing Then
                ' Generate export path
                exportPath = "{input_data.target_folder}" & "\\" & _
                    fso.GetBaseName(file.Name) & ".step"

                ' Export as STEP
                swModel.SaveAs2 exportPath, 0, True, False

                ' Close the model
                swApp.CloseDoc swModel.GetTitle

                processedCount = processedCount + 1
            End If
        End If
    Next file

    MsgBox "Batch export completed. Processed " & processedCount & " files."

End Sub'''

            return {
                "status": "success",
                "message": f"Generated VBA code for batch {input_data.operation_type}",
                "vba_code": vba_code,
                "parameters": {
                    "operation_type": input_data.operation_type,
                    "file_pattern": input_data.file_pattern,
                    "source_folder": input_data.source_folder,
                    "target_folder": input_data.target_folder,
                    "recursive": input_data.recursive,
                },
                "usage_instructions": [
                    "1. Verify source and target folder paths exist",
                    "2. Close any open documents to avoid conflicts",
                    "3. Run the macro - it will process all matching files",
                    "4. Check the target folder for exported files",
                ],
            }

        except Exception as e:
            logger.error(f"Error in generate_vba_batch_export tool: {e}")
            return {
                "status": "error",
                "message": f"Failed to generate VBA code: {str(e)}",
            }

    @mcp.tool()
    async def generate_vba_part_modeling(input_data: dict[str, Any]) -> dict[str, Any]:
        """Generate VBA code for complex part modeling operations.

        Args:
            input_data (dict[str, Any]): The input data value.

        Returns:
            dict[str, Any]: A dictionary containing the resulting values.

        Example:
                            >>> result = await generate_vba_part_modeling(part_input)
        """
        """
        Generate VBA code for advanced part modeling operations.

        Creates macro for complex part features like sweeps, lofts, shells.
        """
        try:
            operation = input_data.get("operation", "shell")
            thickness = input_data.get("thickness", 2.0)

            if operation == "shell":
                vba_code = f"""Sub CreateShell()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swFeatMgr As SldWorks.FeatureManager
    Dim swFeat As SldWorks.Feature

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swFeatMgr = swModel.FeatureManager

    ' Create shell feature
    Set swFeat = swFeatMgr.FeatureShell2( _
        {thickness / 1000.0}, _ ' Thickness (meters)
        False, _ ' OutwardThickness
        False, _ ' MultiThickness
        False, _ ' ShowPreview
        False, _ ' MultipleFaceDef
        False _ ' MultipleThicknessDef
    )

    If swFeat Is Nothing Then
        MsgBox "Failed to create shell"
    Else
        MsgBox "Shell created successfully with thickness: {thickness}mm"
    End If

End Sub"""
            elif operation == "fillet":
                radius = input_data.get("radius", 5.0)
                vba_code = f"""Sub CreateFillet()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swFeatMgr As SldWorks.FeatureManager

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swFeatMgr = swModel.FeatureManager

    ' Create fillet feature
    swFeatMgr.FeatureFillet4( _
        {radius / 1000.0}, _ ' Radius (meters)
        0, _ ' SecondRadius
        0, _ ' RollOnOff
        0, _ ' RollFirstRadius
        0, _ ' RollSecondRadius
        0, _ ' RollSmoothTransition
        0, _ ' ConicRho
        0, _ ' SetbackDistance
        False, _ ' AssemblyFeatureScope
        False, _ ' AutoSelectComponents
        False, _ ' PropagateFeatureToParts
        False, _ ' CreateSelectionSet
        False, _ ' EnableSolidPreview
        0 _ ' CornerType
    )

    swModel.ClearSelection2 True
    MsgBox "Fillet created with radius: {radius}mm"

End Sub"""
            else:
                return {
                    "status": "error",
                    "message": f"Unsupported operation: {operation}",
                }

            return {
                "status": "success",
                "message": f"Generated VBA code for {operation} operation",
                "vba_code": vba_code,
                "parameters": input_data,
                "usage_instructions": [
                    "1. Select the appropriate faces/edges",
                    "2. Run the generated VBA macro",
                    "3. Verify the feature was created correctly",
                ],
            }

        except Exception as e:
            logger.error(f"Error in generate_vba_part_modeling tool: {e}")
            return {
                "status": "error",
                "message": f"Failed to generate VBA code: {str(e)}",
            }

    @mcp.tool()
    async def generate_vba_assembly_mates(input_data: dict[str, Any]) -> dict[str, Any]:
        """Generate VBA code for assembly mate creation.

        Args:
            input_data (dict[str, Any]): The input data value.

        Returns:
            dict[str, Any]: A dictionary containing the resulting values.

        Example:
                            >>> result = await generate_vba_assembly_mates(mate_input)
        """
        """
        Generate VBA code for creating assembly mates.

        Creates macro for various mate types (concentric, distance, parallel, etc).
        """
        try:
            mate_type = input_data.get("mate_type", "concentric")
            component1 = input_data.get("component1", "Part1")
            component2 = input_data.get("component2", "Part2")
            distance = input_data.get("distance", 0.0)

            mate_type_map = {
                "concentric": "swMateType_CONCENTRIC",
                "distance": "swMateType_DISTANCE",
                "parallel": "swMateType_PARALLEL",
                "perpendicular": "swMateType_PERPENDICULAR",
                "coincident": "swMateType_COINCIDENT",
            }

            sw_mate_type = mate_type_map.get(mate_type, "swMateType_CONCENTRIC")

            vba_code = f"""Sub CreateAssemblyMate()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swAssy As SldWorks.AssemblyDoc
    Dim swMateFeats As Variant
    Dim swMate As SldWorks.Feature

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swAssy = swModel

    ' Clear existing selections
    swModel.ClearSelection2 True

    ' Note: Entity selection needs to be done before running this macro
    ' Select appropriate faces/edges on {component1} and {component2}

    ' Create {mate_type} mate
    swMateFeats = swAssy.AddMate5( _
        {sw_mate_type}, _ ' Mate type
        swMateAlign_ALIGNED, _ ' Alignment
        False, _ ' Flip
        {distance / 1000.0}, _ ' Distance (meters)
        0, _ ' Distance2
        0, _ ' Angle
        0, _ ' Angle2
        False, _ ' LockRotation
        0, _ ' WidthMateOption
        0, _ ' For Positioning Only
        0 _ ' LockToSketch
    )

    If IsEmpty(swMateFeats) Then
        MsgBox "Failed to create mate. Check entity selection."
    Else
        Set swMate = swMateFeats(0)
        MsgBox "Mate created: " & swMate.Name
    End If

End Sub"""

            return {
                "status": "success",
                "message": f"Generated VBA code for {mate_type} mate",
                "vba_code": vba_code,
                "parameters": {
                    "mate_type": mate_type,
                    "component1": component1,
                    "component2": component2,
                    "distance": distance,
                },
                "usage_instructions": [
                    "1. Open the assembly document",
                    "2. Select the two faces/edges to mate",
                    "3. Run the generated macro",
                    "4. Verify the mate was created in the feature tree",
                ],
            }

        except Exception as e:
            logger.error(f"Error in generate_vba_assembly_mates tool: {e}")
            return {
                "status": "error",
                "message": f"Failed to generate VBA code: {str(e)}",
            }

    @mcp.tool()
    async def generate_vba_drawing_dimensions(
        input_data: dict[str, Any],
    ) -> dict[str, Any]:
        """Generate VBA code for creating drawing dimensions.

        Creates macro for various dimension types in drawings.

        Args:
            input_data (dict[str, Any]): The input data value.

        Returns:
            dict[str, Any]: A dictionary containing the resulting values.
        """
        try:
            dimension_type = input_data.get("dimension_type", "linear")
            precision = input_data.get("precision", 2)

            vba_code = f'''Sub CreateDrawingDimensions()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swDraw As SldWorks.DrawingDoc
    Dim swView As SldWorks.View
    Dim swDisp As SldWorks.DisplayDimension
    Dim swDim As SldWorks.Dimension

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel

    ' Get active drawing view
    Set swView = swDraw.GetFirstView ' Sheet
    Set swView = swView.GetNextView ' First drawing view

    If swView Is Nothing Then
        MsgBox "No drawing view found"
        Exit Sub
    End If

    swModel.ClearSelection2 True

    ' Note: Select appropriate entities before running
    ' For linear dimensions: select two edges or points
    ' For radial: select arc or circle
    ' For angular: select two lines

    Select Case "{dimension_type}"
        Case "linear"
            Set swDisp = swModel.AddDimension2(0.05, 0.05, 0)
        Case "radial"
            Set swDisp = swModel.AddDimension2(0.05, 0.05, 0)
        Case "angular"
            Set swDisp = swModel.AddDimension2(0.05, 0.05, 0)
        Case "diameter"
            Set swDisp = swModel.AddDimension2(0.05, 0.05, 0)
    End Select

    If Not swDisp Is Nothing Then
        Set swDim = swDisp.GetDimension2(0)
        ' Set precision
        swDim.SetPrecision2 swLinear, {precision}
        MsgBox "Dimension created with {precision} decimal places"
    Else
        MsgBox "Failed to create dimension. Check entity selection."
    End If

End Sub'''

            return {
                "status": "success",
                "message": f"Generated VBA code for {dimension_type} dimension",
                "vba_code": vba_code,
                "parameters": {
                    "dimension_type": dimension_type,
                    "precision": precision,
                },
                "usage_instructions": [
                    "1. Open a drawing with views",
                    "2. Select two edges, points, or appropriate entities",
                    "3. Run the macro to create dimension",
                    "4. Adjust dimension position as needed",
                ],
            }

        except Exception as e:
            logger.error(f"Error in generate_vba_drawing_dimensions tool: {e}")
            return {
                "status": "error",
                "message": f"Failed to generate VBA code: {str(e)}",
            }

    @mcp.tool()
    async def generate_vba_file_operations(
        input_data: dict[str, Any],
    ) -> dict[str, Any]:
        """Generate VBA code for file management operations.

        Args:
            input_data (dict[str, Any]): The input data value.

        Returns:
            dict[str, Any]: A dictionary containing the resulting values.

        Example:
                            >>> result = await generate_vba_file_operations(file_input)

                        Creates macro for custom properties, PDM operations, etc.
        """
        try:
            operation = input_data.get("operation", "custom_properties")

            if operation == "custom_properties":
                property_name = input_data.get("property_name", "Material")
                property_value = input_data.get("property_value", "Steel")

                vba_code = f'''Sub SetCustomProperties()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swCustPropMgr As SldWorks.CustomPropertyManager
    Dim configNames As Variant
    Dim i As Integer

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    ' Get configuration names
    configNames = swModel.GetConfigurationNames

    ' Set property for all configurations
    For i = 0 To UBound(configNames)
        Set swCustPropMgr = swModel.Extension.CustomPropertyManager(configNames(i))

        swCustPropMgr.Add3 "{property_name}", swCustomInfoText, _
            "{property_value}", swCustomPropertyAddOption_ReplaceValue
    Next i

    ' Also set at file level
    Set swCustPropMgr = swModel.Extension.CustomPropertyManager("")
    swCustPropMgr.Add3 "{property_name}", swCustomInfoText, _
        "{property_value}", swCustomPropertyAddOption_ReplaceValue

    MsgBox "Custom property '{property_name}' set to '{property_value}'"

End Sub'''

            elif operation == "pack_and_go":
                target_folder = input_data.get("target_folder", "C:\\PackAndGo")

                vba_code = f'''Sub PackAndGo()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swPackAndGo As SldWorks.PackAndGo
    Dim pgStatus As Long
    Dim pgWarnings As Long

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    Set swPackAndGo = swApp.GetPackAndGo

    ' Set Pack and Go settings
    swPackAndGo.IncludeDrawings = True
    swPackAndGo.IncludeSimulationResults = False
    swPackAndGo.IncludeToolboxComponents = False
    swPackAndGo.FlattenToSingleFolder = True

    ' Set destination folder
    swPackAndGo.SetSaveToName swModel.GetTitle, "{target_folder}"

    ' Execute Pack and Go
    swPackAndGo.PackAndGo2 pgStatus, pgWarnings

    If pgStatus = 0 Then
        MsgBox "Pack and Go completed successfully"
    Else
        MsgBox "Pack and Go failed with status: " & pgStatus
    End If

End Sub'''
            else:
                return {
                    "status": "error",
                    "message": f"Unsupported operation: {operation}",
                }

            return {
                "status": "success",
                "message": f"Generated VBA code for {operation}",
                "vba_code": vba_code,
                "parameters": input_data,
                "usage_instructions": [
                    "1. Open the target document",
                    "2. Run the generated macro",
                    "3. Check results in properties or file system",
                ],
            }

        except Exception as e:
            logger.error(f"Error in generate_vba_file_operations tool: {e}")
            return {
                "status": "error",
                "message": f"Failed to generate VBA code: {str(e)}",
            }

    @mcp.tool()
    async def generate_vba_macro_recorder(input_data: dict[str, Any]) -> dict[str, Any]:
        """Generate VBA code using macro recording patterns.

        Args:
            input_data (dict[str, Any]): The input data value.

        Returns:
            dict[str, Any]: A dictionary containing the resulting values.

        Example:
                            >>> result = await generate_vba_macro_recorder(recorder_input)
        """
        try:
            operation = input_data.get("operation", "start_recording")

            if operation == "start_recording":
                vba_code = """Sub StartMacroRecording()
    Dim swApp As SldWorks.SldWorks
    Set swApp = Application.SldWorks

    ' Enable macro recording
    swApp.UnloadAddIn "SldWorks.Addin.Utilities.MacroRecorder"
    swApp.LoadAddIn "SldWorks.Addin.Utilities.MacroRecorder"

    ' Note: Use Tools > Macro > Record in SolidWorks interface
    ' This code prepares the environment for recording

    MsgBox "Macro recording environment prepared. Use Tools > Macro > Record to start."

End Sub"""

            elif operation == "stop_recording":
                vba_code = """Sub StopMacroRecording()
    Dim swApp As SldWorks.SldWorks
    Set swApp = Application.SldWorks

    ' Note: Use Tools > Macro > Stop Record in SolidWorks interface
    ' This code helps manage the recording session

    MsgBox "Stop recording using Tools > Macro > Stop Record"

End Sub"""

            elif operation == "create_template":
                macro_name = input_data.get("macro_name", "CustomMacro")
                vba_code = f"""Sub {macro_name}Template()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    ' Add more variables as needed

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    ' TODO: Add your custom automation code here
    ' This template provides the basic SolidWorks API structure

    ' Error handling
    If swModel Is Nothing Then
        MsgBox "No active document"
        Exit Sub
    End If

    ' Your automation logic goes here...

    MsgBox "Custom macro template ready for customization"

End Sub"""
            else:
                return {
                    "status": "error",
                    "message": f"Unsupported operation: {operation}",
                }

            return {
                "status": "success",
                "message": f"Generated VBA code for macro {operation}",
                "vba_code": vba_code,
                "parameters": input_data,
                "usage_instructions": [
                    "1. Open SolidWorks VBA editor (Alt+F11)",
                    "2. Create new module and paste code",
                    "3. Customize as needed for your workflow",
                ],
            }

        except Exception as e:
            logger.error(f"Error in generate_vba_macro_recorder tool: {e}")
            return {
                "status": "error",
                "message": f"Failed to generate VBA code: {str(e)}",
            }

    # Core VBA generation tools
    tool_count = 10
    return tool_count