AnsweredAssumed Answered

Get current temporary SolidWorks folder

Question asked by Jana Stahn on Feb 6, 2019
Latest reply on Feb 6, 2019 by Artem Taturevych

Whenever I start SolidWorks, it creates a temporary folder in "C:\Users\<username>\AppData\Local\Temp\swxXXX" where "XXX" is some positive integer (usually 4-5 digits). Every start of SolidWorks creates a new such folder with a different integer "XXX".

Is there some way of getting that current folder (or at least the integer "XXX") during a SolidWorks session by using the SolidWorks API?


Use case:

That folder is also the one where virtual components are stored in (inside \swxXXX\VC~~\).

What I want to do is:

1. Open some non-virtual assembly. By that, SolidWorks writes all virtual components of that assembly into \swxXXX\VC~~\....

2. Get the content of a custom property of that assembly that I have stored in a prior SolidWorks session. The content is the path of a certain virtual subcomponent - not necessarily a top-level component; can be deeply nested. But it is not the full path but only the part of the path after \swxXXX\, so that is remains constant throughout SolidWorks sessions.

3. Open the file whose (partial) path I got in 2 to do some stuff with it. For that I need to create the full path which is only possible when knowing the XXX in \swxXXX\.


A possible workaround that I do NOT want to do:

Open some non-virtual assembly which contains virtual components. Traverse its components until I get a virtual one. Then call IComponent2.GetPathName() and I have the full path "C:\Users\<username>\AppData\Local\Temp\swxXXX\VC~~\..." from which I can extract the integer "XXX" I need. But I do not want to do this because it will make my program slower. It would be nicer to get the path without needing to open or traverse anything.