| T O P I C R E V I E W |
| rcr1991 |
Posted - 05/21/2006 : 11:22:57 PM Origin Version (Select Help-->About Origin): 7.5 Operating System: winxp
I have 600+ origin projects that I want to open, print the graph, and close. There is one graph in each project. Does anyone have any examples of how to do this? I am good at visual basic, but don't know labtalk or origin c.
Thanks,
Rob |
| 7 L A T E S T R E P L I E S (Newest First) |
| Mike Buess |
Posted - 05/29/2006 : 7:51:55 PM Hi Rob,
You inserted the LabTalk section inside the Origin C function where it does not belong. The entire code (with save) should read like this...
void PrintGraphsInFolder(string strPath = "") { if( strPath.IsEmpty() ) strPath = BrowseGetPath(); if( strPath.IsEmpty() ) return; StringArray saFileList; FindFiles(saFileList,strPath,"opj"); out_str("Printing..."); for(int i=0;i<saFileList.GetSize();i++) { if( Project.Open(strPath + saFileList[i]) ) { out_str(saFileList[i]); LT_execute("run.section(" + __FILE__ + ",Print)"); Project.Save(strPath + saFileList[i]); } } out_str("Done!"); }
#ifdef LabTalk [Print] doc -e P { page.active=1; xx1=x1; xx2=x2; lay -a; if( page.nlayers>1 ) { lay -o 2 {lay -a}; }; if( page.nlayers>3 ) { lay -o 4 {lay -a}; }; x1=xx1; x2=xx2; print; }; doc -s; #endif
Mike Buess Origin WebRing Member |
| rcr1991 |
Posted - 05/29/2006 : 5:56:16 PM The SAVE function doesn't work in code below--suggestions on how to modfy to get it to save after the rescaling of Y-axes?
Thanks,
Rob
// Start your functions here. void PrintGraphsInFolder(string strPath = "") { if( strPath.IsEmpty() ) strPath = BrowseGetPath(); if( strPath.IsEmpty() ) return; StringArray saFileList; FindFiles(saFileList,strPath,"opj"); out_str("Printing..."); for(int i=0;i<saFileList.GetSize();i++) { if( Project.Open(strPath + saFileList[i]) ) { out_str(saFileList[i]); LT_execute("run.section(" + __FILE__ + ",Print)"); Project.Save(strPath + saFileList[i]); } } #ifdef LabTalk [Print] doc -e P { page.active=1; xx1=x1; xx2=x2; lay -a; if( page.nlayers>1 ) { lay -o 2 {lay -a}; }; if( page.nlayers>3 ) { lay -o 4 {lay -a}; }; x1=xx1; x2=xx2; print; }; doc -s; #endif out_str("Done!"); } |
| Mike Buess |
Posted - 05/23/2006 : 5:05:09 PM The following changes should work if your layers are X-linked to layer 1. If plots look ok in a small scale test then remove the // from the Project.Save line in step 1.
1. Replace the LT_execute statement in the PrintGraphsInFolder function with these two lines...
LT_execute("run.section(" + __FILE__ + ",Print)"); //Project.Save(strPath + saFileList[i]);
2. Add this to the bottom of your Origin C file (don't omit the first #ifdef and last #endif statements)...
#ifdef LabTalk [Print] doc -e P { page.active=1; xx1=x1; xx2=x2; lay -a; if( page.nlayers>1 ) { lay -o 2 {lay -a}; }; if( page.nlayers>3 ) { lay -o 4 {lay -a}; }; x1=xx1; x2=xx2; print; }; doc -s; #endif
Here are a few places to look for programming tips... http://www.originlab.com/index.aspx?s=9 http://www.originlab.com/index.aspx?s=9&lm=+151 http://www.originlab.com/index.aspx?s=8&lm=243 http://www.nmrtools.com/labtalk/index.html
Mike Buess Origin WebRing Member |
| rcr1991 |
Posted - 05/23/2006 : 2:24:22 PM Mike,
Excellent, wow that works well. And you were 100% right--running out of paper, then toner were my biggest challenges!
To make this perfect I would like to rescale three of the four layers on the page. They are all X-linked to layer 1, and that works fine. But I want to rescale to show all on Y axis on layer 1, 2 and 4. Not all of them because layer 3 has a break, and rescaling ruins the advantages of the break.
Is there a way to add code that would rescale layer 1,2,and 4 Y-axis before printing? Don't care about saving it that way, though that would be a plus. BTW, those Y-axes are all set to auto, but they don't rescale on their own.
Last ?: What resources (n=books, web sites etc) can you recommend to learn Origin C/LabTalk? The online help isn't geared for a beginner, and there aren't many examples to guide a newbee. Suggestions? |
| Mike Buess |
Posted - 05/22/2006 : 09:23:30 AM Hi Rob,
Origin C is better than LabTalk for creating file lists. Add the function below to CodeBuilder's workspace as described here and use it by entering PrintGraphsInFolder D:\data\project1\ in the script window. If you omit the path you'll get a folder selection dialog. If you include the path make sure to end it with a slash, '\'. Actual printing is done with the LabTalk command suggested by Deanna. The doc -s LabTalk command prevents the prompt to save each project.
...Probably good to test it on a folder with only two or three projects. If that works you only have to worry about paper supply. :)
void PrintGraphsInFolder(string strPath = "") { if( strPath.IsEmpty() ) strPath = BrowseGetPath(); if( strPath.IsEmpty() ) return; StringArray saFileList; FindFiles(saFileList,strPath,"opj"); out_str("Printing..."); for(int i=0;i<saFileList.GetSize();i++) { if( Project.Open(strPath + saFileList[i]) ) { out_str(saFileList[i]); LT_execute("doc -e P {Print}; doc -s"); } } out_str("Done!"); }
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 05/22/2006 09:52:38 AM
Edited by - Mike Buess on 05/22/2006 09:56:49 AM |
| rcr1991 |
Posted - 05/22/2006 : 07:34:58 AM Deanna,
Thanks for the tips.
The projects are in a folder 'd:\data\project1'.
The names of the projects are are unique, but ALL .opj files in a folder need to be processed. So if labtalk can get a list of *.opj files in a named directory (I can manually insert the directory name in the script for each of the projects (1....n)) then it could open a project, and print it.
I tried to manually open 10 files, and print all open graphs. It does print them, but it loses the LABEL information that is in each graph. It renames all graphs to the first that is open. This won't work b/c i need to know what is being printed, hence the label. If I manually open a project, and print the graph, that does work.
Thanks for your offer of help.
Rob |
| Deanna |
Posted - 05/22/2006 : 02:41:18 AM Hello Rob.
Here are some commands that will help.
Labtalk commands document -o projectname document -of projectname can close the current project and open another project with the name given.
And the labtalk command doc -e P print can print all the graphs in the active project.
You did not mention where the projects are and the names of the projects. If you can provide this information, maybe I can write a complete script for the batch printing.
Deanna OriginLab GZ Office
Edited by - Deanna on 05/22/2006 04:00:27 AM |
|
|