Scripting for project layoutI have a script that generates 5 windows, and want to use the script to organise the output into a project format, and arrange the layout.
I would like the window list on the right. On the left, I would like two rows :
top row, I want two graphs side by side.
bottom row, I want three tables displayed in tabs.
I have come up with the below script, but it doesn't do what I want. Currently all 5 get displayed in a single row on five different tabs, with the windows list on the right.
Can someone point me in the right direction?
Project = new project();
Move to Project( destination( Project ), windows( {"Table1" ,"Table2" , "Table3", "Graph1", "Graph2"} ));
Project << Set Layout(
H Splitter Box(
<<SET sizes=""></SET>Re: Scripting for project layoutSimplest possible example of creating a project, creating a data table, and saving that table to the project contents:
new Project(
Run Script(
dt = New Table( "My Table",
Add Rows( 3 ),
New Column( "Column 1",
Set Values( [1, 2, 3] )
)
);
dt << Save As("$PROJECT/my table.jmp");
);
);
The path variable $PROJECT maps to the Project Contents of the current project (and as such is only usable inside a project). It would be perfectly fine to create the tables outside the project and then move them in, though if that isn't necessary for some external reason it's generally more efficient to create everything directly in the project the first time.
Re: Scripting for project layoutThe main body of the script generates 3 data files and links them together. The way it is written now files are saved to C drive Temp folder and then moved into project. I would like to add a contents section and add these three files into it with the script. I think then I would update the analysis that is done to open the files in the project and make process capability graphs.
Re: Scripting for project layoutThe project layout code should be (more or less) the same as before. The difference in JMP 16 is, when you go to save your content you can save it inside the project file if you choose. You do this automatically from a script, if you want, though I'd need to know a bit more about your project to recommend a specific method.
Re: Scripting for project layoutJMP 16 makes an improvement for the project platform by incorporating the files into the project file for saving and transferring. This is a nice improvement. My JMP 15 script to move files from a report into a project file still works in 16 but I would like to update to use the new features of JMP16. I am not sure what the new script structure would look like for this case. Any suggestions? Attached is what my script looks like now (not run able since all files based on my PC and data wrangling done by earlier part of script.
Re: Scripting for project layoutYou can set a particular TabBox to have a certain current tab using the regular TabBox APIs. (The interactive JMP Scripting Index is a good resources to learn these). Here's one way of doing it with the exampe we've been workign with:
Project = new project();
Move to Project( destination( Project ), windows( {table1, table2, table3} ));
Project << Set Layout(
H Splitter Box(
<<SET sizes=""></SET>
We just save the tab box in a variable when we create it, then use that variable later to set the tab we want to be current.
Re: Scripting for project layoutHi Aaron,
Finally got it to work, thank you so much!
I was trying to set the window ID when creating the tables and graph, and I think that was not working. So it's doing the layout correctly now.
Just another related question : how do I get it to display a specific tab? Is there a way they can be ordered? It's always displaying the same Table by default but that's not the one I want displayed.
Re: Scripting for project layoutSorry it's still not working. Here is an example of the first method, using (mostly) your script and some sample data table:
table1 = Open("$SAMPLE_DATA/Big Class.jmp");
table1 << Set Window ID("Table1");
graph1 = table1 << Run Script("Bivariate");
graph1 << Set Window ID("graph1");
table2 = Open("$SAMPLE_DATA/Iris.jmp");
table2 << Set Window ID("Table2");
graph2 = table2 << Run Script("Graph Builder Contour Plot");
graph2 << Set Window ID("graph2");
table3 = Open("$SAMPLE_DATA/Baseball.jmp");
table3 << Set Window ID("Table3");
Project = new project();
Move to Project( destination( Project ), windows( {table1, table2, table3} ));
Project << Set Layout(
H Splitter Box(
<<SET sizes=""></SET>
And here is one way to do it whout setting the IDs:
table1 = Open("$SAMPLE_DATA/Big Class.jmp");
graph1 = table1 << Run Script("Bivariate");
table2 = Open("$SAMPLE_DATA/Iris.jmp");
graph2 = table2 << Run Script("Graph Builder Contour Plot");
table3 = Open("$SAMPLE_DATA/Baseball.jmp");
Project = new project();
Move to Project( destination( Project ), windows( {table1, table2, table3} ));
Project << Set Layout(
H Splitter Box(
<<SET sizes=""></SET>
Lastly, here's a version that avoids the Move to Project() by opening the windows in the project from the start:
Project = new project();
Project << Run Script(
table1 = Open("$SAMPLE_DATA/Big Class.jmp");
table1 << Set Window ID("Table1");
graph1 = table1 << Run Script("Bivariate");
graph1 << Set Window ID("graph1");
table2 = Open("$SAMPLE_DATA/Iris.jmp");
table2 << Set Window ID("Table2");
graph2 = table2 << Run Script("Graph Builder Contour Plot");
graph2 << Set Window ID("graph2");
table3 = Open("$SAMPLE_DATA/Baseball.jmp");
table3 << Set Window ID("Table3");
);
Project << Set Layout(
H Splitter Box(
<<SET sizes=""></SET>
Hopefully one of those can be modified to work with your script.
Re: Scripting for project layoutHi Aaron,
I tried what you suggested, however still no luck, same error message.
What I don't understand is : I created a new window, then used Set Window ID to give it an ID, but that ID doesn't seem to be recognised by Tab Box().
Re: Scripting for project layoutMy fault, I think. Get Window() needs to know where to look (since windows in the project can have the same titles as windows outside it). So instead of
Get Window("Table1")
(whihc is looking for a window called "Table1" not in a project), we need to use
Get Window(Project(Project), "Table1")
where the inside "Project" is the name you picked for your project variable at the top of your script:
Project = new project();
All together, something like this should work:
Tab Page Box(
Window ID( Get Window(Project(project), "Table1") << Get Window ID())
)
And yes, this is definitely something we're hoping to make easier in a future JMP release. 
Re: Scripting for project layoutThanks for your help. Still having difficulties, sorry I am a beginner in JSL...
When I use the second option, I get an error message about scriptable objects :
Send Expects Scriptable Object in access or evaluation of 'Send' , Get Window( "Table1" ) << /*###*/
Get Window ID() /*###*/
I assume I need to make these objects scriptable, but again not sure how to do that?
I also tried the first option which I thought would work. I managed to create new windows for each of the reports, and used the set window ID command to give them an ID, however it is still not working.
Re: Scripting for project layoutYou're right--those GUIDs would be different every time. I won't bore you with the details of why we didn't just have it use window titles, but there's good (albeit complicated) reason for the IDs. The best thing to do when scripting a project manually like this is either to set window IDs earlier in the script using
mywindow << Set Window ID("window1");
or use Get Window ID() directly in your layout:
Tab Page Box(
Title( "Table1" ),
Window ID( Get Window("Table1") << Get Window ID())
)
Note that the Title() there is only used to print a friendler message if the window with the given ID can't be foud, and to make things a bit more human readable. It doesn't do anything functionally, so you can go ahead and leave it out if that makes your life easier.
Re: Scripting for project layoutHi Aaron,
Thanks for this. I didn't know how to get the script layout so that's great!
So I have done this, and the issue I have is that in the log, each of the tabs looks a bit like this:
Tab Page Box(
Title( "Table1" ),
Window ID( "e516a5e8-d5c2-954e-90a6-ba6b719dae98" )
I removed all the window ID bits, but it still doesn't work, so I assume it needs the window ID bit. However, these window ID numbers seem like combinations of random letters and numbers which will be different every time the script runs, so I can't specify these in advance. Is there a way to find the window IDs of the windows that are open? I have looked for how to do this but can't see how to do it.
Re: Scripting for project layoutOne of the best ways to write project layouts in JSL is to open the project, use the drag and drop interface to set the arrangement you want, and then save the layout using JSL. To do this, create a new JSL script (outside the project), then run
Get Project("Untitled") << Get Layout();
or
Get Project(1) << Get Layout();
using the title or index of the project you want to get the layout of. This will dump the referenced project's layout to the log, which you can then adapt to work with your project creation script.
(You can do the same thing from inside a project, and can even use the [this project()] shortcut to run the command, but then the resulting layout will include the script window you opened to do it with, so it's often easier to do it from outside).