Search code examples
pythonsolidworks

Analyzing 10k solidworks parts through python


I have been looking around on and off for the last week to see if anybody has performed this type of work. Unfortunately I have found very little that is python specific.

I have a repository with ~10k solidworks parts. I would like to analyse these files in batch and collect information like volume, material, etc, so to get some general statistical information. Ideally this would be in python but solutions in other languages are more than welcome.

Most answers I found are about creating addons in VB,C#, C++ to interact with Solidworks API but nothing about doing general statistical analysis of just the parts. I don't want to interact with the application or build features, I just want to look at what's inside the files without having Solidworks. I am also working on Linux which is not supported by Solidworks.


Solution

  • Нi, 6F4E37

    I see two ways to get what you want from solidworks files, unfortunately they both involve Windows and C#/VB code.

    1. Without SolidWorks application. Use SW Document manager - a library that allows you to access meta information of your parts. You will be able to get some information about your part including volume.

      I'm unaware of any attempts to run Document Manager on Wine, please share your results if you'll try.

      Note that Document manager library license is free, provided that you have active SolidWorks subscription.

    2. Using SolidWorks API. You don't have to create an add-in, you can connect to solidworks from a standalone application :

      SldWorks swApp = (SldWorks)Activator.CreateInstance(System.Type.GetTypeFromProgID("SldWorks.Application"));
      

      Obviously for that approach you'll need to have solidowrks installed on your machine.

      Also note that SolidWorks is not the most stable application, and it'll crash every 200-400 files that you process, so you you'll choose this approach you'll need to keep an eye on SolidWorks instance and restart it if needed.