Subscribe Bookmark RSS Feed

How to automatically save run chart image in script?

dustin_lewis_ri

Community Trekker

Joined:

Mar 8, 2016

Hello All,

I created this script to open a text file, filter the data, and then generate a run chart.

Is there away I can also have the script automatically save the run chart as a .gif/.jpeg file in a chosen directory?

The exact script can be seen below. Thank you for the help! 

Open(

"R:\Operations\Engineering\FTP DATA\FT_LPC_Results.txt",

Date = Numeric,

Time = Numeric,

Lot # = Character,

Part # = Character,

Brush # = Character,

Station # = Numeric,

LPC = Numeric,

Column 8 = Numeric,

Column 9 = Numeric,

Column 10 = Numeric,

Column 11 = Numeric,

Column 12 = Numeric,

Column 13 = Numeric,

Column 14 = Numeric,

Column 15 = Numeric,

Column 16 = Numeric,

Column 17 = Character

),

End Of Line( CRLF, CR, LF ),

End Of Field( Tab, Comma ),

Strip Quotes( 1 ),

Use Apostrophe as Quotation Mark( 0 ),

Scan Whole File( 1 ),

Labels( 1 ),

Column Names Start( 1 ),

Data Starts( 2 ),

Lines To Read( All ),

Year Rule( "10-90" )

);

Current Data Table() << Data Filter(

columns( :Part # ),

Where( :Part # == "H2FEN-70-31NM-0317" ),

Display( :Part #, Size( 204, 259 ), List Display )

);

Data Table( "FT_LPC_Results" ) << Subset( Copy formula( 0 ) );

Sample Label( :Lot # ),

Sample Size( 1 ),

KSigma( 3 ),

Chart Col( :Name( "LPC >0.1" ), Run Chart( Show Center Line( 0 ) ) ),

{},

"Run Chart of LPC >0.1",

OutlineBox,

Set Title( "H2FEN-70-31NN-0317 - LPC" )

),

{"Run Chart of LPC >0.1"},

"2",

ScaleBox,

{Min( 39.2945275076211 ), Max( 2195.92103353172 ), Inc( 250 ),

Add Ref Line( 2000, Solid, {255, 0, 0}, "USL 2000" )}

),

{"Run Chart of LPC >0.1"},

"1",

ScaleBox,

{Min( 15230.3237 ), Max( 19677.7118706835 ), Inc( 8 ),

Rotated Labels( 1 )}

),

{"Run Chart of LPC >0.1"},

"Run Chart",

FrameBox,

Frame Size( 897, 415 )

),

{"Run Chart of LPC >0.1"},

"Run Chart",

FrameBox( 2 ),

Frame Size( 69, 415 )

);

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

To verify my approach, I created a data table with the same columns your data table has, then I ran your Data Filter, Subset and Control Chart Code, with my 2 changes, and it worked without issue.  Here is the copy of your code with my 2 changes. The 2 changes are that I added "cc=" in front of the control chart platform so I could reference it to get the control chart to save.  The second change is the "report(cc) << save picture(................." at the end of the script.  That line will have to be changed to point to a folder path where you can save the output jpg.  Attached is the jpg file the script produced.

Open(

"R:\Operations\Engineering\FTP DATA\FT_LPC_Results.txt",

Date = Numeric,

Time = Numeric,

Lot # = Character,

Part # = Character,

Brush # = Character,

Station # = Numeric,

LPC = Numeric,

Column 8 = Numeric,

Column 9 = Numeric,

Column 10 = Numeric,

Column 11 = Numeric,

Column 12 = Numeric,

Column 13 = Numeric,

Column 14 = Numeric,

Column 15 = Numeric,

Column 16 = Numeric,

Column 17 = Character

),

End Of Line( CRLF, CR, LF ),

End Of Field( Tab, Comma ),

Strip Quotes( 1 ),

Use Apostrophe as Quotation Mark( 0 ),

Scan Whole File( 1 ),

Labels( 1 ),

Column Names Start( 1 ),

Data Starts( 2 ),

Lines To Read( All ),

Year Rule( "10-90" )

);

Current Data Table() << Data Filter(

Add Filter(

columns( :Part # ),

Where( :Part # == "H2FEN-70-31NM-0317" ),

Display( :Part #, Size( 204, 259 ), List Display )

);

Data Table( "FT_LPC_Results" ) << Subset( Copy formula( 0 ) );

cc=Control Chart(

Sample Label( :Lot # ),

Sample Size( 1 ),

KSigma( 3 ),

Chart Col( :Name( "LPC >0.1" ), Run Chart( Show Center Line( 0 ) ) ),

Dispatch( {}, "Run Chart of LPC >0.1", OutlineBox, Set Title( "H2FEN-70-31NN-0317 - LPC" ) ),

{"Run Chart of LPC >0.1"},

"2",

ScaleBox,

{Min( 100.2945275076211 ), Max(130.92103353172 ), Inc( 250 ),

Add Ref Line( 2000, Solid, {255, 0, 0}, "USL 2000" )}

),

{"Run Chart of LPC >0.1"},

"1",

ScaleBox,

{Min( 15230.3237 ), Max( 19677.7118706835 ), Inc( 8 ), Rotated Labels( 1 )}

),

Dispatch( {"Run Chart of LPC >0.1"}, "Run Chart", FrameBox, Frame Size( 897, 415 ) ),

Dispatch( {"Run Chart of LPC >0.1"}, "Run Chart", FrameBox( 2 ), Frame Size( 69, 415 ) );

 

report(cc) << save picture("<change this to the path you want to use>\thepicture.jpg");

Jim
7 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

The script you copied into your discussion question, did not make a correct paste.  Therefore, it is incomplete.  However, here is a simple run chart example that after it has run, it saves the output as a jpg file

names default to here(1);

dt = open("$SAMPLE_DATA/big class.jmp");

cc=Control Chart,

Sample Size( 5 ),

KSigma( 3 ),

Chart Col( :height, Run Chart( Show Center Line( 0 ) ) )

);

report(cc) << save picture("<put in your path>  \thepicture.jpg");

Jim
dustin_lewis_ri

Community Trekker

Joined:

Mar 8, 2016

Hi Jim,

Thank you for the quick reply.  This is the complete script below and is exactly what is in the script, minus the Save Picture function you gave me.

I am new to JMP, so bear with me : )  I could be doing this the hard way, but I included a screenshot of what all is going on when I run the script.

I could not get the save picture function to work...Thanks for your time.

11138_pastedImage_0.png

Open(

"R:\Operations\Engineering\FTP DATA\FT_LPC_Results.txt",

columns(

Date = Numeric,

Time = Numeric,

Lot # = Character,

Part # = Character,

Brush # = Character,

Station # = Numeric,

LPC = Numeric,

Column 8 = Numeric,

Column 9 = Numeric,

Column 10 = Numeric,

Column 11 = Numeric,

Column 12 = Numeric,

Column 13 = Numeric,

Column 14 = Numeric,

Column 15 = Numeric,

Column 16 = Numeric,

Column 17 = Character

),

Import Settings(

End Of Line( CRLF, CR, LF ),

End Of Field( Tab, Comma ),

Strip Quotes( 1 ),

Use Apostrophe as Quotation Mark( 0 ),

Scan Whole File( 1 ),

Labels( 1 ),

Column Names Start( 1 ),

Data Starts( 2 ),

Lines To Read( All ),

Year Rule( "10-90" )

)

);

Current Data Table() << Data Filter(

Add Filter(

columns( :Part # ),

Where( :Part # == "H2FEN-70-31NM-0317" ),

Display( :Part #, Size( 204, 259 ), List Display )

)

);

Data Table( "FT_LPC_Results" ) << Subset( Copy formula( 0 ) );

Control Chart(

Sample Label( :Lot # ),

Sample Size( 1 ),

KSigma( 3 ),

Chart Col( :Name( "LPC >0.1" ), Run Chart( Show Center Line( 0 ) ) ),

SendToReport(

Dispatch(

{},

"Run Chart of LPC >0.1",

OutlineBox,

Set Title( "H2FEN-70-31NN-0317 - LPC" )

),

Dispatch(

{"Run Chart of LPC >0.1"},

"2",

ScaleBox,

{Min( 39.2945275076211 ), Max( 2195.92103353172 ), Inc( 250 ),

Add Ref Line( 2000, Solid, {255, 0, 0}, "USL 2000" )}

),

Dispatch(

{"Run Chart of LPC >0.1"},

"1",

ScaleBox,

{Min( 15230.3237 ), Max( 19677.7118706835 ), Inc( 8 ),

Rotated Labels( 1 )}

),

Dispatch(

{"Run Chart of LPC >0.1"},

"Run Chart",

FrameBox,

Frame Size( 897, 415 )

),

Dispatch(

{"Run Chart of LPC >0.1"},

"Run Chart",

FrameBox( 2 ),

Frame Size( 69, 415 )

)

)

)

Solution

To verify my approach, I created a data table with the same columns your data table has, then I ran your Data Filter, Subset and Control Chart Code, with my 2 changes, and it worked without issue.  Here is the copy of your code with my 2 changes. The 2 changes are that I added "cc=" in front of the control chart platform so I could reference it to get the control chart to save.  The second change is the "report(cc) << save picture(................." at the end of the script.  That line will have to be changed to point to a folder path where you can save the output jpg.  Attached is the jpg file the script produced.

Open(

"R:\Operations\Engineering\FTP DATA\FT_LPC_Results.txt",

Date = Numeric,

Time = Numeric,

Lot # = Character,

Part # = Character,

Brush # = Character,

Station # = Numeric,

LPC = Numeric,

Column 8 = Numeric,

Column 9 = Numeric,

Column 10 = Numeric,

Column 11 = Numeric,

Column 12 = Numeric,

Column 13 = Numeric,

Column 14 = Numeric,

Column 15 = Numeric,

Column 16 = Numeric,

Column 17 = Character

),

End Of Line( CRLF, CR, LF ),

End Of Field( Tab, Comma ),

Strip Quotes( 1 ),

Use Apostrophe as Quotation Mark( 0 ),

Scan Whole File( 1 ),

Labels( 1 ),

Column Names Start( 1 ),

Data Starts( 2 ),

Lines To Read( All ),

Year Rule( "10-90" )

);

Current Data Table() << Data Filter(

Add Filter(

columns( :Part # ),

Where( :Part # == "H2FEN-70-31NM-0317" ),

Display( :Part #, Size( 204, 259 ), List Display )

);

Data Table( "FT_LPC_Results" ) << Subset( Copy formula( 0 ) );

cc=Control Chart(

Sample Label( :Lot # ),

Sample Size( 1 ),

KSigma( 3 ),

Chart Col( :Name( "LPC >0.1" ), Run Chart( Show Center Line( 0 ) ) ),

Dispatch( {}, "Run Chart of LPC >0.1", OutlineBox, Set Title( "H2FEN-70-31NN-0317 - LPC" ) ),

{"Run Chart of LPC >0.1"},

"2",

ScaleBox,

{Min( 100.2945275076211 ), Max(130.92103353172 ), Inc( 250 ),

Add Ref Line( 2000, Solid, {255, 0, 0}, "USL 2000" )}

),

{"Run Chart of LPC >0.1"},

"1",

ScaleBox,

{Min( 15230.3237 ), Max( 19677.7118706835 ), Inc( 8 ), Rotated Labels( 1 )}

),

Dispatch( {"Run Chart of LPC >0.1"}, "Run Chart", FrameBox, Frame Size( 897, 415 ) ),

Dispatch( {"Run Chart of LPC >0.1"}, "Run Chart", FrameBox( 2 ), Frame Size( 69, 415 ) );

 

report(cc) << save picture("<change this to the path you want to use>\thepicture.jpg");

Jim
dustin_lewis_ri

Community Trekker

Joined:

Mar 8, 2016

It worked like a charm! Thank you very much for your assistance.

dustin_lewis_ri

Community Trekker

Joined:

Mar 8, 2016

Jim,

Is it possible to have the script automatically open an Excel document and insert the image to the document.

That would eliminate the need to insert the image(Around thirty images) each time. That would be awesome.

Thanks again

txnelson

Super User

Joined:

Jun 22, 2012

I am not aware of being able to do this.  Maybe a Visual Basic program could be written to run the Control Charts in JMP and then take the captured objects and place them into Excel.

Jim
jerry_cooper

Staff

Joined:

Jul 10, 2014

You might find this blog helpful:

How to automatically update a Word or PowerPoint file from JMP report

This doesn't "open" a Microsoft document and insert the image, but it almost gets you there.  It would require creating the Excel document using the Insert and Link feature to insert images. So, generate your document and insert files once and, thereafter, your JSL could automatically generate the images and save them in the linked location. The next time the Excel document is opened up the updated, linked image would be used.