Can I use multi threading with Solidworks API?

Hi All,
I am working on a project to export Solidworks parts into dxf files using This API . I should activate part configuration prior to exporting the document using IModelDoc2.ShowConfiguration2("configurationName"); . Consequently I should process parts one by one! Is there a way to somehow process a batch of items in parallel?
This Article From Javeline suggest multi threading is possible in Solidworks but I found many questions on solidworks forum that suggest otherwise.

Not possible. All of your API calls will execute on the main thread of SOLIDWORKS with the possible exception of event handling code that might be triggered for a background thread started by SOLIDWORKS when opening large assemblies (ie concurrent loading of multiple documents).

You literally have no control over threading with SOLIDWORKS. That probably won’t change.

If you are using Winforms and you attempt to async wait API calls, you will actually make SOLIDWORKS slower because of cross thread overhead.

Achieving a responsive UI is truly a tricky deal.

If you want to achieve some sort of concurrency, try loading multiple instances of SOLIDWORKS and split your work into smaller chuncks that each process can handle independently.

1 Like

Thanks Amen, that was my last solution to create multiple instances of the application, I doubt it would be as easy as that though, I’ll update this post once I’ve tested it.

I was going to suggest one of the dozen ways to speed up the API, like disabling the feature tree, but I don’t think any of those methods will make exporting faster. Maybe hiding the window will do something.

Here’s my current list of options:

4 Likes

Some good resource! Thanks for sharing!

SolidWorks provides extensive documentation for its API. It’s worth checking the official documentation or contacting SolidWorks support directly to confirm whether multi-threading is supported and under what circumstances. You might want to conduct some experiments to test whether multi-threading works as expected in your specific scenario. This can involve writing a simple test script to perform operations on multiple parts simultaneously and observing the behavior. Even if the SolidWorks API itself doesn’t directly support multi-threading, you can still utilize multi-threading in your application using .NET’s Task Parallel Library (TPL) or similar frameworks. You can parallelize certain tasks in your application while still ensuring that SolidWorks API calls are made sequentially and on the main thread.