Hi Ravi,
You can use code such as posted below. Note that there is no simple command at this point to programmatically rearrange all layers in a specific configuration such as say 2x3 although that can be done from the GUI manually using the layer tool. So for now you would need to get and set the layer properties such as width, height, x, y offset etc.
Another suggestion I have is that you could instead do the following:
1> create a custom template with max number of layers that you would want to use
2> create a new graph page using this custom template
3> add data plots to as many layers as applicable depending on the number of datasets you have
4> delete all empty layers
This may work a bit better than having to create and arrange layers perhaps.
Easwar
OriginLab
void add_layer()
{
// Create a new graph page using existing template
GraphPage gpg;
// Use Origin.otp which has one layer, or any custom template
gpg.Create("Origin");
// Use LT layer command to add another layer to the graph page
// Layer command has many options such as linking new layer to
// existing active layer etc - see LT language reference help file
LT_execute("layer -n;");
// Get the index of the layer just added - should be the active layer
int nLyIndex = page_active_layer_index(gpg);
// Declare OC layer object using this index
GraphLayer gly = gpg.Layers(nLyIndex);
// Do manipulations to this added layer such as resizing it
// Set dimension in inches
gly.Dimension.Units.nVal = 1;
// Set top, left, width, height
gly.Dimension.Top.dVal = 1;
gly.Dimension.Left.dVal = 5;
gly.Dimension.Width.dVal = 5;
gly.Dimension.Height.dVal = 3;
}