Skip to main content

Wrapper for SolidWorks and PDM APIs for a streamlined, Pythonic workflow.

Project description

Copyright (c) 2024 Sean Yeatts. All rights reserved.

This module wraps the SolidWorks and PDM APIs for a streamlined, Pythonic workflow.

Key Features

  • Intuitive Pythonic syntax for interacting with SolidWorks documents & PDM files.

  • Timestamped logging for insights into automated task performance.

  • Full API documentation detailing module components.

Navigate to the API Reference for a complete walkthrough of the module.

Quickstart

Key import statements :

import solidwrap                         # top level module import
from solidwrap import SolidWorks, Vault  # access to SolidWorks and PDM processes
from solidwrap import Filepath           # generic container for file objects

The following methods must be called before you can utilize the SolidWrap API :

solidworks = SolidWorks(version=2023)   # instantiate SolidWorks
vault = Vault(name='VAULT-NAME')        # instantiate PDM Vault ( case sensitive )

solidworks.connect()   # connect to SolidWorks client
vault.connect()        # connect to PDM Vault client

Example - a simple script that exports a group of ‘.SLDPRT’ documents to various formats :

# IMPORTS
from solidwrap import SolidWorks, Vault         # core classes
from solidwrap import Filepath, SWExportFormat  # containers


# FUNCTIONS
def export_example(solidworks: SolidWorks, vault: Vault) -> None:

    # Set up some example files
    files = [
        Filepath(fr"C:\{vault.name}\Test_Part_01.SLDPRT"),
        Filepath(fr"C:\{vault.name}\Test_Part_02.SLDPRT"),
        Filepath(fr"C:\{vault.name}\Test_Part_03.SLDPRT")
    ]

    # Export a variety of formats
    for file in files:
        if (document := solidworks.open(file)):
            solidworks.export(document, SWExportFormat.IMAGE)      # .png
            solidworks.export(document, SWExportFormat.PARASOLID)  # .x_t
            solidworks.close(document)


# MAIN DEFINITION
def main() -> None:

    # Instantiate core objects
    solidworks = SolidWorks(2023)
    vault = Vault('My-Vault')

    # Initialize connections
    if not solidworks.connect(headless=False):
        return None
    if not vault.connect():
        return None

    # Do some stuff...
    export_example(solidworks, vault)

    # Terminate connections
    solidworks.disconnect(silent=False)
    vault.disconnect()


# TOP LEVEL ENTRY POINT
if __name__ == '__main__':
    main()

Installation

Prerequisites

  • Python 3.8 or higher is recommended

  • pip 23.0 or higher is recommended

For a pip installation

Open a new Command Prompt. Run the following command:

py -m pip install solidwrap

For a local installation

Extract the contents of this module to a safe location. Open a new terminal and navigate to the top level directory of your project. Run the following command:

py -m pip install "DIRECTORY_HERE\solidwrap\dist\solidwrap-2.0.0.tar.gz"
  • DIRECTORY_HERE should be replaced with the complete filepath to the folder where you saved the SolidWrap module contents.

  • Depending on the release of SolidWrap you’ve chosen, you may have to change 2.0.0 to reflect your specific version.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solidwrap-2.1.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

solidwrap-2.1.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file solidwrap-2.1.1.tar.gz.

File metadata

  • Download URL: solidwrap-2.1.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for solidwrap-2.1.1.tar.gz
Algorithm Hash digest
SHA256 82a305b74bcfae4e10da7b25f20d8fbfd14dd78c5f66c4c5ba617aec910bcb24
MD5 c8eab355f1b5ee9e7470994af9a7d5e2
BLAKE2b-256 06970e829a4102a3faac3d9047ee758ab07da4b04c674f88b20baf099a1a0c30

See more details on using hashes here.

File details

Details for the file solidwrap-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: solidwrap-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for solidwrap-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c16c2024e5e059dc358d657a9502e04ed166063d5917172e4e15c4358021b008
MD5 1fbfc2c96cf054065ffe5fb35d1fc5d3
BLAKE2b-256 e98fef6bc2fd6c7f960a2265d8f9ee020e0c641d28c23fa4dbe3ce60a460cf29

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page