cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
ckronig
Level III

Scripting for project layout

I 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( {0.85, 0.15} ),			
		V Splitter Box(
			<<Set Sizes( {0.3, 0.7} ),
				H Splitter Box(
				<<Set Sizes( {0.5, 0.5} ),
			Tab Page Box( Window ID( "graph1" ) ),
			Tab Page Box( Window ID( "graph2" ) )
			),
			Tab Box(
			Tab Page Box( Window ID( "Table1" ) ),
			Tab Page Box( Window ID( "Table2" ) ),
			Tab Page Box( Window ID( "Table3" ) )
			),			

			),
			Tab Page Box(
				Title( "Window List" ),
				Window ID( "Windows" )
			),
		)  
	,
	),
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Scripting for project layout

Sorry 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( {0.85, 0.15} ),			
		V Splitter Box(
		<<Set Sizes( {0.3, 0.7} ),
			H Splitter Box(
			<<Set Sizes( {0.5, 0.5} ),
				Tab Page Box( Window ID( "graph1" ) ),
				Tab Page Box( Window ID( "graph2" ) )
			),
			Tab Box(
				Tab Page Box( Window ID( "Table1" ) ),
				Tab Page Box( Window ID( "Table2" ) ),
				Tab Page Box( Window ID( "Table3" ) )
			),			
		),
		Tab Page Box(
			Title( "Window List" ),
			Window ID( "Windows" )
		),
	),
);

 

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( {0.85, 0.15} ),			
		V Splitter Box(
		<<Set Sizes( {0.3, 0.7} ),
			H Splitter Box(
			<<Set Sizes( {0.5, 0.5} ),
				Tab Page Box( Window ID( graph1 << Get Window ID() ) ),
				Tab Page Box( Window ID( graph2 << Get Window ID() ) )
			),
			Tab Box(
				Tab Page Box( Window ID( table1 << Get Window ID() ) ),
				Tab Page Box( Window ID( table2 << Get Window ID() ) ),
				Tab Page Box( Window ID( table3 << Get Window ID() ) )
			),			
		),
		Tab Page Box(
			Title( "Window List" ),
			Window ID( "Windows" )
		),
	),
);

 

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( {0.85, 0.15} ),			
		V Splitter Box(
		<<Set Sizes( {0.3, 0.7} ),
			H Splitter Box(
			<<Set Sizes( {0.5, 0.5} ),
				Tab Page Box( Window ID( "graph1" ) ),
				Tab Page Box( Window ID( "graph2" ) )
			),
			Tab Box(
				Tab Page Box( Window ID( "Table1" ) ),
				Tab Page Box( Window ID( "Table2" ) ),
				Tab Page Box( Window ID( "Table3" ) )
			),			
		),
		Tab Page Box(
			Title( "Window List" ),
			Window ID( "Windows" )
		),
	),
);

 

Hopefully one of those can be modified to work with your script.

View solution in original post

13 REPLIES 13

Re: Scripting for project layout

One 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).

ckronig
Level III

Re: Scripting for project layout

Hi 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 layout

You'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.

 

ckronig
Level III

Re: Scripting for project layout

Thanks 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 layout

My 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. ;)

ckronig
Level III

Re: Scripting for project layout

Hi 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 layout

Sorry 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( {0.85, 0.15} ),			
		V Splitter Box(
		<<Set Sizes( {0.3, 0.7} ),
			H Splitter Box(
			<<Set Sizes( {0.5, 0.5} ),
				Tab Page Box( Window ID( "graph1" ) ),
				Tab Page Box( Window ID( "graph2" ) )
			),
			Tab Box(
				Tab Page Box( Window ID( "Table1" ) ),
				Tab Page Box( Window ID( "Table2" ) ),
				Tab Page Box( Window ID( "Table3" ) )
			),			
		),
		Tab Page Box(
			Title( "Window List" ),
			Window ID( "Windows" )
		),
	),
);

 

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( {0.85, 0.15} ),			
		V Splitter Box(
		<<Set Sizes( {0.3, 0.7} ),
			H Splitter Box(
			<<Set Sizes( {0.5, 0.5} ),
				Tab Page Box( Window ID( graph1 << Get Window ID() ) ),
				Tab Page Box( Window ID( graph2 << Get Window ID() ) )
			),
			Tab Box(
				Tab Page Box( Window ID( table1 << Get Window ID() ) ),
				Tab Page Box( Window ID( table2 << Get Window ID() ) ),
				Tab Page Box( Window ID( table3 << Get Window ID() ) )
			),			
		),
		Tab Page Box(
			Title( "Window List" ),
			Window ID( "Windows" )
		),
	),
);

 

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( {0.85, 0.15} ),			
		V Splitter Box(
		<<Set Sizes( {0.3, 0.7} ),
			H Splitter Box(
			<<Set Sizes( {0.5, 0.5} ),
				Tab Page Box( Window ID( "graph1" ) ),
				Tab Page Box( Window ID( "graph2" ) )
			),
			Tab Box(
				Tab Page Box( Window ID( "Table1" ) ),
				Tab Page Box( Window ID( "Table2" ) ),
				Tab Page Box( Window ID( "Table3" ) )
			),			
		),
		Tab Page Box(
			Title( "Window List" ),
			Window ID( "Windows" )
		),
	),
);

 

Hopefully one of those can be modified to work with your script.

ckronig
Level III

Re: Scripting for project layout

Hi 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 layout

You 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( {0.85, 0.15} ),			
		V Splitter Box(
		<<Set Sizes( {0.3, 0.7} ),
			H Splitter Box(
			<<Set Sizes( {0.5, 0.5} ),
				Tab Page Box( Window ID( "graph1" ) ),
				Tab Page Box( Window ID( "graph2" ) )
			),
			tabletabs = Tab Box(
				Tab Page Box( Window ID( "Table1" ) ),
				Tab Page Box( Window ID( "Table2" ) ),
				Tab Page Box( Window ID( "Table3" ) )
			),			
		),
		Tab Page Box(
			Title( "Window List" ),
			Window ID( "Windows" )
		),
	),
);

tabletabs << Set Selected(2);

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.