Macro solidworks, how to save the results of a simulation?

Hi all

I created a macro allowing me to successively launch a statistical study of my assembly by changing the point of application of the force. I isolate the resulting displacement (URES) in a Variant variable using the function: GetDisplacementForEntities (see the link: http://help.solidworks.com/2014/English/api/swsimulationapi/SolidWorks.Interop.cosworks~SolidWorks.Interop.cosworks.ICWResults~GetDisplacementForEntities.html).

I then want to save this result before launching my new simuation. However, the other backup functions of the Solidworks API seem to concern assembly, part or drawing files (see the save3 and saveas functions).

Does anyone know of a way to save the result of a study?

Thank you all for your help,

Thomas

Hello

I found this for the options for saving results, but nothing concrete to save!

http://help.solidworks.com/2015/english/api/swsimulationapi/SolidWorks.Interop.cosworks~SolidWorks.Interop.cosworks.swsSaveResultsOption_e.html

 

Maybe some info here to use Excel for results:

http://www.engineersrule.com/hack-a-simulation-using-the-solidworks-api/

Edit: otherwise, the probes could also be suitable (I don't know exactly what the purpose is):

http://help.solidworks.com/2015/french/SolidWorks/cworks/t_Probing_Result_Plots.htm?id=b1b2e8801c2f4e7ba65ddb0809a0b2a1#Pg0

 

Hello

To save the results of a simulation on SolidWorks you do:
- Simulation using the simulation assistant

-At the end of your simulation you can generate a WORD report.
 

(at the end of each simulation you can make a Word report which will be done automatically by Solidworks)!


simulation_enregistrement.png

Hello

Thank you for your answers even if for the moment it doesn't solve my problem. The report is too general because I want to automatically isolate the URES displacement.

I feel like my current code is doing the hardest because it isolates the URES move and the stock in a variable, the question is: is it possible to save the contents of an object variable?

2 Likes

Yes, it is quite possible to save the variable in a text or CSV file (which can be opened with Excel) with VBA instructions:

'###### for the text file
f = FreeFile
Open "c:/test.csv" For Append As #f open CSV or TXT file
Writing to the properties file
Print #f, "1; 1st result; " & RESUL1
Print #f, "2; 2nd result; " & RESUL2
Close #f

 

You can record your simulation.
Solidworks puts together a Word file for you, automatically made.
This also works for eco-design.

Test

Good luck if not for your macro

 

Thank you .PL for your answer, the problem remains the same, the print function only accepts variables such as assembly, part or drawing or I want to save only the result of the simu...