Matlab script locks up after it finishes

3 views (last 30 days)
Jeremy
Jeremy on 3 Sep 2019
Edited: Jeremy on 3 Sep 2019
I have a short script which communicates with Solidworks to get the xyz coordinates of points in a sketch. It's a port of what I've written already in Python, where I've essentially had to wrap the normal COM commands with an invoke function in Matlab. I've also done other scripts like this to communicate between Matlab and Solidworks, and this is the only problematic one. The script will finish executing, with the run button displaying again, and it outputs what I want it to, but Matlab essentially hangs up. I can double click on variables in the workspace and examine them, but I can't run any more scripts, nor can I clear the workspace. I have to kill the entire app to use it again. I've attached the code below and indented the line where I think something is going wrong. Strangely, I can add stuff below this line, and it still executes and outputs correctly, but the indented line is where I can no longer effectively use the program after the script finishes executing.
sw = actxserver('SldWorks.Application');
swModel = invoke(sw, 'ActiveDoc');
swSelMgr = invoke(swModel, 'SelectionManager');
swFeat = invoke(swSelMgr, 'GetSelectedObject6', 1, -1);
swSketch = invoke(swFeat, 'GetSpecificFeature2');
pointList = invoke(swSketch, 'GetSketchPoints2');
borderMatrix = []
for i = 1:size(pointList, 1)
x = invoke(pointList{i, 1}, 'X') * 1000;
y = invoke(pointList{i, 1}, 'Y') * 1000;
z = invoke(pointList{i, 1}, 'Z') * 1000;
borderMatrix = [borderMatrix; x, y, z];
end
disp('Test')

Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!