The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Rename graphs after/during batch Analysis
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Matthias Mueller

18 Posts

Posted - 11/18/2014 :  08:31:57 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9.1
Operating System: Windows 7

Hi there,

I used an analysis template for a batch analysis (as described in the user guide 9.1). In my case the batch process does the following:

1) import X files
2) linear regression on the imported data
3) plot the data and the regression line

Each plot contains the imported data and an already existing data set in the analysis template, which is shown in all X plots.
The batch analysis produces X workbooks, each containing: the data, the linear fit results, the graph (in a worksheet).

Now here's my question: How can I change the (long or short) names of the graphs' workbook or worksheet? (not manually). I'd like to export all graphs and each file should have the same name as the workbook/name of the imported file. During my batch analysis the worksheet, which contains the graph, just gets the name "Graph1".

Is there a way to define the name in my batch analysis template (using e.g. "%(1@W, @W,SYSTEM.IMPORT.FILENAME$)", which I use to show the filename on the graph)?



Thanks for your help!

Matthias

EDIT: Please see the 2nd picture below: If I open a graph window, it is named "Graph2", but I want it to be named "T633" or "T_633", like the workbook, which contains the graph.




Edited by - Matthias Mueller on 11/19/2014 08:35:59 AM

jasonzhao

China
262 Posts

Posted - 11/20/2014 :  02:43:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Would you like to send your analysis template and sample data to <tech@originlab.com>
so we can have a try.

Best regards,
Jason Zhao
OriginLab Tech Service
Go to Top of Page

Matthias Mueller

18 Posts

Posted - 11/20/2014 :  03:26:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jason,

thanks, I just sent my data.

Kind regards

Matthias
Go to Top of Page

jasonzhao

China
262 Posts

Posted - 11/21/2014 :  04:01:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Please try this script which change the name of graph sheet follows the bookname. paste script in script window, select all, and click ENTER.


doc -e w       // loop through all book
{
page.active=4;  // active graph sheet(i.e. sheet4)

wks.name$ = %H;   // change name follows the book name
%H=;
}


Best regards,
Jason Zhao
OriginLab Tech Service

Edited by - jasonzhao on 11/21/2014 04:12:00 AM
Go to Top of Page

cdrozdowski111

USA
247 Posts

Posted - 11/21/2014 :  3:28:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Matthias,

By my understanding you wanted to rename not just the worksheet with the graph but the actual graph window so that when you export the graph, it will be the same name as the workbook long name and not just "Graph1", "Graph2", etc. Here is a method to do this (and more) automatically.

Open your Analysis Template. On your graph, select one of your Text Labels (e.g. the one you mention in your initial post) and right click to open the Programming Control dialog.

In the dialog:
1) Set the Substitution Level to 1.
2) Set Script, Run After to "Data Change"
3) Add below script

%J = %H;
%K = %(1@W, @PN);

The script sets the %J string register to the short name of the graph window (e.g. Graph1) and sets the %K string register to the short name of the workbook that contains the data for plot 1 of the graph. We will use those later.

Save your Analysis Template.

Now, open the Batch Process dialog. If you already have a Theme for your batch processing then good. If not, you'll need to create one and use it in the future.

At the bottom of the dialog, there is a text edit control labelled "Script after Each Process". Enter the following script in the control and save your dialog theme. It is documented in the comments.

// Make sure %J string register points to the graph window and %K points to the workbook
if ((exist(%J, 3) != 3) || (exist(%K, 2) != 2))
{
    // If not, dump error mesage to Message Log and stop script
    int nOld = type.redirection;
    type.redirection = 1024;
    type "Failed to change graph name in Analysis Template!";
    type.redirection = nOld;
    return;
}

// Get ranges for the graph, the workbook, and the worksheet containing the embedded graph
// based on the string registers.
// Embedded graph worksheet is 4 (see below). You might need to change that.
range rngGraph = [%J];
range rngBook = [%K];
range rngSheet = [%K]4;

// Set graph long name to workbook long name
rngGraph.longname$ = rngBook.longname$;

// Set worksheet long name to workbook long name. Note I prefixed it with  "Graph: "
rngSheet.longname$ = "Graph: %(rngBook.longname$)"; 

// Set column comments for embedded graph to workbook long name. Note I prefixed it with  "Graph: "
rngSheet.col1.comment$ = "Graph: %(rngBook.longname$)";

// Clear string registers
%J="";
%K="";


Now save your theme and give it a try!

You might want to do some additional testing of it with your data including importing multiple files at the same time. I don't have your data so my testing was based on simple data.
Go to Top of Page

Matthias Mueller

18 Posts

Posted - 11/24/2014 :  04:03:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
@Jason Zhao

Hey Jason,
thanks for your reply! This scripts helps to rename the worksheets, but it does not rename the graph window of the embedded graph.

@cdrozdowski111

Hi,
thanks very much for your help. As far as I can judge it till now, this script does, what I was looking for. It renames the graph windows, and I don't have to rename them manually when I export the graphs.


Both your replies are a good starting point for me in Origin-scripting. Thanks!

Kind regards,

Matthias
Go to Top of Page

cdrozdowski111

USA
247 Posts

Posted - 11/24/2014 :  06:42:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Matthias,

If you want to delve deeper into LabTalk scripting, I have found that the PDF version of the LabTalk User Guide (link below) to be quite helpful. While the same (and in fact more) information is found online, the PDF version presents the material in a more linear form like a book, good for gradual learning.

http://cloud.originlab.com/pdfs/Origin91_Documentation/English/LabTalk_Scripting_Guide_E.pdf
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000