T O P I C R E V I E W |
bo257 |
Posted - 07/23/2002 : 9:13:09 PM Hi; I am new to Labtalk and trying to import multiple data-files, plot them in a graph and finally export them as a JPEG file one at a time. I have sofar mainly copied a script I found on these pages( "Import Multiple, 3D Plot and JPEG Export" abutler 7 136 11/02/2001 10:52:14 AM by: CStorey) but failed in the last part. I have two problems: 1-how do I export these Graphs as a JPG file and how do I define the filepath where they are supposed to be saved? 2-At the end of the script I am drawing a vertical line at a fixed position on the x-axis. Can one use instead of a fixed position a number which has to be obtained from a cell of the worksheet (same cell for all worksheets)?
Thanks a lot in advance for any suggestions.
Barbaros
/// FDlog Import script FDLog.DlgName$="Select Files to Import."; FDLog.ShowComment=0; FDlog.path$="C:\DATA\cpp\fpp measurements\"; // Default path FDLog.numtypes=3; FDLog.type1$=[TXT files]*.TXT; FDLog.type2$=[DAT files]*.DAT; FDLog.type3$=[All files]*.*; FDLog.defType=1; FDLog.multiOpen.sort=0;
If(FDLog.MultiOpen()!=0/0) { Loop(nn,1,FDLog.MultiOpen.Count) { win -t wks "Fpp for Cpp.OTW" WKS$(nn);//Open a Worksheet template %R=%H; win -a WKS$(nn); FDLog.Get(A, nn);//Get name of data file open -w %A;//Import data %W=%H; win -r %H WKS$(nn); work -s 1 0 2 0; //select colums for plot work -p 202 "Fpp for CPP.OTG" Graph$(nn);//Open a graph template and plot %R=%H; win -a Graph$(nn);//Activate current Graph window draw -n vline -l -v 0.436;//draw a vertical line at x=0.436 save -i C:\DATA\cpp\fpp measurements\Graph$(nn).OGG;//save Graph window win -c WKS$(nn);//close worksheet win -c Graph$(nn);//close graph }; }; Return;
|
5 L A T E S T R E P L I E S (Newest First) |
CStorey |
Posted - 07/24/2002 : 4:21:55 PM Hi Barbaros,
Hmmm...no good ideas what went wrong. I've seen this before when I installed a patch I had already installed. Make sure that your templates weren't modified by the patches. As a side note Origin doesn't like M$ long name formats with spaces, your template uses these, maybe try to use "_" instead. (Eg. change "Fpp for CPP.OTG" to "Fpp_for_Cpp.OTG") Otherwise try to use the full path to the template. %Y can be used for the Origin directory, so that a template "line.OTG" in the dir C:\Program Files\Origin61\mytemplates\line.otg could be shortened to %Ymytemplates\line.otg. Note there is no "\" after the %Y since Origin puts one in %Y already.
Hope this solves everything!
Craig Storey Origin WebRing Member - http://g.webring.com/hub?ring=originwebring |
bo257 |
Posted - 07/24/2002 : 4:07:39 PM hi craig;
thanks again for your help. I had to install the Service Release patches for Origin 6.0. Now the export of graphs as JPEG files works fine, but I cannot anylonger plot the Graphs using templates. It simply plots the data on a simple xy graph. During the download process of the Service Release pathces it kept giving me the error messages: Patch Warning-Old file doesn't exist. DO you have an idea what went wrong?
Barbaros |
CStorey |
Posted - 07/24/2002 : 1:56:49 PM Hi Barbaros,
If you omit those two lines does it work?? There not that critical, they control wether a dialog will appear on each iteration of the export command and what temporary format should be used before JPG conversion. I think there's another problem here though. Have you made sure to instal all the Service Release patches for Origin 6.0? If not I recommend doing so! Some of the export features were buggy in Origin 6.0 release but the patches improved things. Maybe these commands were implemented in the patches. They are free downloads from the main Origin page under "DOWNLOADS/SERVICE RELEASES" look on page 2 for Origin 6.0 stuff.
Craig Storey Origin WebRing Member - http://g.webring.com/hub?ring=originwebring |
bo257 |
Posted - 07/24/2002 : 1:08:56 PM Hi Craig;
thank you very much for your help. The "draw line" part works now fine, but I have still a problem with exporting the graph as a .JPG document. After running the script I get these two messages on the script window:
IMAGE.SHOWOPTIONS is an illegal name for defining a variable. It must not start with a number, nor an operator and may not contain a dot.
IMAGE.EXPORT.TEMPRASTER is an illegal name for defining a variable. It must not start with a number, nor an operator and may not contain a dot.
Do you have an idea of what goes wrong (I am using Version 6.0)?
Thanks once more;
Barbaros
//=================================== // Multi Import, Plot, Export JPGs //===================================
%L="C:\DATA\cpp\fpp measurements\JPG\"; image.ShowOptions=0; // No Image Export Dialogs!! image.export.tempRaster=2; // Temp file for Raster Type should be BMP, if too large use EMF
/// FDlog Import script FDLog.DlgName$="Select Files to Import."; FDLog.ShowComment=0; FDlog.path$="C:\DATA\cpp\fpp measurements\"; // Default path FDLog.numtypes=3; FDLog.type1$=[TXT files]*.TXT; FDLog.type2$=[DAT files]*.DAT; FDLog.type3$=[All files]*.*; FDLog.defType=1; FDLog.multiOpen.sort=0;
If(FDLog.MultiOpen()!=0/0) { Loop(nn,1,FDLog.MultiOpen.Count) { win -t wks "Fpp for Cpp.OTW" WKS$(nn);//Open a Worksheet template %R=%H; win -a WKS$(nn); FDLog.Get(A, nn);//Get name of data file open -w %A;//Import data %W=%H; win -r %H WKS$(nn); work -s 1 0 2 0; //select colums for plot work -p 202 "Fpp for CPP.OTG" Graph$(nn);//Open a graph template and plot %R=%H; win -a Graph$(nn);//Activate current Graph window
////////// Draw vertical line based on Wks Cell value ////////////// //draw -n vline -l -v WKS$(nn)_ColumnName[cellnumber];// ////////////////////////////////////////////////////////////////////
save -i C:\DATA\cpp\fpp measurements\Graph$(nn).OGG;//save Graph window image.filename$="%L%H.JPG"; // Use graph name and %L path image.exportPixel(JPG,640,480,24,0); //Origin 6.0 Format win -c WKS$(nn);//close worksheet win -c Graph$(nn);//close graph }; }; Return;
|
CStorey |
Posted - 07/24/2002 : 12:18:59 PM Hello,
Looks like a great start! Here's a little help with the vertical line and JPG export. (Undebugged or tested)
For the vertical line just fill in the Columnname and cellnumber you want to refer and it should work, LabTalk is very flexible this way.
I've included 7.x(6.1) and 6.0 JPG export formats that work. Notice I've set the width=640 and height=480. You can play with this but be warned that there some bad combinations that may give your graphs a less than ideal appearance. (other good choices are 800x600 and 1024x768)
To specify the path for export just define it as %L at the beginning, notice that %L is used in the eport command filename, or set %L to the FDLog.path$ value after you do the import if you want the JPGs to apppear in the import directory. (%L=FDLOg.path$; in the inner loop)
//=================================== // Multi Import, Plot, Export JPGs //===================================
%L="Directory for JPG export"; image.ShowOptions=0; // No Image Export Dialogs!! image.export.tempRaster=2; // Temp file for Raster Type should be BMP, if too large use EMF
/// FDlog Import script FDLog.DlgName$="Select Files to Import."; FDLog.ShowComment=0; FDlog.path$="C:\DATA\cpp\fpp measurements\"; // Default path FDLog.numtypes=3; FDLog.type1$=[TXT files]*.TXT; FDLog.type2$=[DAT files]*.DAT; FDLog.type3$=[All files]*.*; FDLog.defType=1; FDLog.multiOpen.sort=0;
If(FDLog.MultiOpen()!=0/0) { Loop(nn,1,FDLog.MultiOpen.Count) { win -t wks "Fpp for Cpp.OTW" WKS$(nn);//Open a Worksheet template %R=%H; win -a WKS$(nn); FDLog.Get(A, nn);//Get name of data file open -w %A;//Import data %W=%H; win -r %H WKS$(nn); work -s 1 0 2 0; //select colums for plot work -p 202 "Fpp for CPP.OTG" Graph$(nn);//Open a graph template and plot %R=%H; win -a Graph$(nn);//Activate current Graph window
// draw -n vline -l -v 0.436;//draw a vertical line at x=0.436
////////// Draw vertical line based on Wks Cell value ////////////// draw -n vline -l -v WKS$(nn)_ColumnName[cellnumber]; ////////////////////////////////////////////////////////////////////
save -i C:\DATA\cpp\fpp measurements\Graph$(nn).OGG;//save Graph window
////////////// Export Graph To JPG ///////////////////////////////// image.filename$="%L%H.JPG"; // Use graph name and %L path image.export.PagePixel(JPG,640,480,24,0); //Origin 7.x, 6.1 format!! // image.exportPixel(JPG,640,480,24,0); //Origin 6.0 Format ////////////////////////////////////////////////////////////////////
win -c WKS$(nn);//close worksheet win -c Graph$(nn);//close graph }; }; Return;
Craig Storey Origin WebRing Member - http://g.webring.com/hub?ring=originwebring |
|
|