Hello Matlab Forum,
I'm having an issue printing sub charts to file. I essentially want to open all Sub Charts in a Stateflow diagram and print them individually to pdf files for a large model, I thought this would be easy, but it only seems easy to work for charts. Nothing more than opening up all charts and doing a automatic "Print -> Print to File -> PDF"
The following (using a matlab example will work for a chart but not for a sub chart) if you pass in a sub chart on a state it errors and falls over, in this case I would pass '-isa' a 'Stateflow.State' but ensure it is a sub chart too.
Any ideas/ alternates greatly appreciated, I've been stuck on this a while. I might have to resort to producing a docx through the Reporting API and parsing through that in VBA, or using the clipboard somehow maybe, don't really want to open and close a ton of windows though.
chart = find(sfroot, '-isa','Stateflow.Chart','Name','Gear_logic');chart.fitToView;chartHandle = get_param(string(chart.Path) +'/','Handle');sfprint(chartHandle, 'jpg')
I can display charts on screen as shown below, but I can't export them to file using print of sfprint, what am I missing: –
chartColl = find(sfroot, '-isa', 'Stateflow.State', '-and', 'IsSubchart', 1 );for i=1 : length(chartColl) chart= chartColl(i,1); %chart.fitToView;
chart.view; print ('c:\temp\testy.pdf','pdf'); %print '-dpdf' + ' C:\Temp\' + string(chart.id) + '.pdf';
%dump the image/ file in the clipboard somehow
%sfprint(gcb,'pdf', 'C:\Temp\' + string(chart.id) + '.pdf',0);
%chtHand= get_param(string(chart.Path) + '/', 'Handle');
%sfprint(chtHand,'pdf', 'C:\Temp\' + string(chart.id) + '.pdf');
end
Cheers for any help
Richard
Best Answer