Matlab script locks up after it finishes

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')

답변 (0개)

카테고리

도움말 센터File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

릴리스

R2019a

질문:

2019년 9월 3일

편집:

2019년 9월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by