필터 지우기
필터 지우기

Print all Sub charts in a Stateflow model to individual files

조회 수: 12 (최근 30일)
Richard Good
Richard Good 2020년 10월 28일
댓글: Richard Good 2020년 10월 28일
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

채택된 답변

Nicolas Schoonbroodt
Nicolas Schoonbroodt 2020년 10월 28일
Hi Richard,
I'm not quite sure that this is what your are looking for, but maybe this could help. You don't need to pass a handle to sfprint, you can directly pass the object, and I think that you could simply do this:
allSubcharts = find(sfroot, 'IsSubchart',1);
for idx=1:length(allSubcharts)
sfprint(allSubcharts(idx), 'jpg');
end
  댓글 수: 1
Richard Good
Richard Good 2020년 10월 28일
For some reason the internet and the help pointed me at saveas which didn't work for me. Nothing pointed me at sfprint until I raised a case. That came back using the handle technique so I didn't twig I could just use an object. Thanks for the correction!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Complex Logic에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by