Son Trinh-Van

Problem in controlling Solidworks from Matlab

Discussion created by Son Trinh-Van on Jan 18, 2021

Anyone could help me, please? I have connected Matlab and Solidworks and then I tried to open a Motion analysis, in which it contains the results of the motion. My code as below:

 

swApp=actxserver('SLDWORKS.application');
invoke(swApp,'Visible','true');

swAssem=invoke(swApp,'NewDocument','foldername\Assem1.SLDASM', 2, 0, 0);
swModel=invoke(swApp,'ActiveDoc');
swModelDocExt=invoke(swModel,'Extension');
swMotionMgr=invoke(swModelDocExt,'GetMotionStudyManager');
swMotionStudy=invoke(swMotionMgr,'GetMotionStudy','Motion Study 1');

swMotionStudyResults=invoke(swMotionStudy,'GetResults','4');
swplotFeature=invoke(swMotionStudyResults,'GetPlotCount');

 

swplotFeature returns a value of 2 that is because, in the results folder, I have 2 plots.

Now my problem is that I want to use the Matlab command to export these plots to .csv or .txt files using the ExportCSVfile method. However, it does NOT work.

I have tried with the following command:

 

invoke(swMotionStudyResults,'ExportCSVFile','Plot2','Filename');

 

Does anyone have any idea how to export the data 

Outcomes