Hi everyone,
I have a JSL script that outputs about 10 graphs in individual windows. I am working on a way to input each graph into its own slide in a powerpoint. Due to the complexities of the pictures I saw there was a way to use python's python-pptx package to accomplish this and I am able to create all the slides with a title but am unable to get the picture into the powerpoint at all. Below is the code snippet I am working with and the line that is commented out is the line that it's breaking at. I know this since the commented out line puts the picture and powerpoint in the right folder and opens seamlessly. But when uncommented the picture is saved but the following line where the ppt gets saved to the file folder never happens and likewise Jmp says it can't open the non-existant file. I have tried everything from using f strings to concatenations of the string to get the picture in the ppt but am unable. Any help would be much appreciated. Thanks!
dt = Open("$SAMPLE_DATA/Big Class.jmp");
biv = dt << Bivariate( Y( :height ), X( :weight ) );
ppt_dir = "C:\Users\neel\Documents\new jmp\";
number = "12345678";
graph holding = H List Box();
graph holding << append(Report(biv));
pic holding = H List Box();
pic holding << append(graph holding << get picture);
pic_file = "example.png";
pic holding << Save Picture(ppt_dir || pic_file);
Python Init();
plog = Python Execute({ppt_dir, number, pic_file}, {img_path, left, top, height},
"\[
from pptx import Presentation
from pptx.util import Inches
img_path = ppt_dir + pic_file
prs = Presentation()
slide_1 = prs.slides.add_slide(prs.slide_layouts[0])
slide_1.shapes.title.text = "Review of " + number
slide_2 = prs.slides.add_slide(prs.slide_layouts[5])
slide_2.shapes.title.text = "Results"
slide_3 = prs.slides.add_slide(prs.slide_layouts[5])
slide_3.shapes.title.text = "Summary"
left = top = Inches(2)
#pad_summary_pic = slide_3.shapes.add_picture(img_path, left, top, height=height)
prs.save(rf"{ppt_dir}{number} Review.pptx")
]\"
);
Python Term();
//Open PPT
ppt = ppt_dir || number || " Review.pptx";
Open(ppt);
Above works without the picture being added.
dt = Open("$SAMPLE_DATA/Big Class.jmp");
biv = dt << Bivariate( Y( :height ), X( :weight ) );
ppt_dir = "C:\Users\neel\Documents\new jmp\";
number = "12345678";
graph holding = H List Box();
graph holding << append(Report(biv));
pic holding = H List Box();
pic holding << append(graph holding << get picture);
pic_file = "example.png";
pic holding << Save Picture(ppt_dir || pic_file);
Python Init();
plog = Python Execute({ppt_dir, number, pic_file}, {img_path, left, top, height},
"\[
from pptx import Presentation
from pptx.util import Inches
img_path = ppt_dir + pic_file
prs = Presentation()
slide_1 = prs.slides.add_slide(prs.slide_layouts[0])
slide_1.shapes.title.text = "Review of " + number
slide_2 = prs.slides.add_slide(prs.slide_layouts[5])
slide_2.shapes.title.text = "Results"
slide_3 = prs.slides.add_slide(prs.slide_layouts[5])
slide_3.shapes.title.text = "Summary"
left = top = Inches(2)
pad_summary_pic = slide_3.shapes.add_picture(img_path, left, top, height=height)
prs.save(rf"{ppt_dir}{number} Review.pptx")
]\"
);
Python Term();
//Open PPT
ppt = ppt_dir || number || " Review.pptx";
Open(ppt);
This one with the add_picture uncommented doesn't.
Thanks,
Neel