T O P I C R E V I E W |
b2user |
Posted - 08/19/2005 : 11:10:51 AM Origin Version (Select Help-->About Origin): 7.5 Operating System: Windows XP
I have one X Coloumn, and more than 200 Y Coloumns following. Is there a quick way to make seperate graphs (dots and line) and directly save them as gif files?
Thank you very much for your help. |
8 L A T E S T R E P L I E S (Newest First) |
Mike Buess |
Posted - 08/24/2005 : 11:07:14 AM You need OriginPro to export to GIF. If you have the standard version you'll have to try something else. See what choices are available when you select File > Export.
Mike Buess Origin WebRing Member |
b2user |
Posted - 08/24/2005 : 10:40:22 AM I also tried with breakpoints and the debugger. It does create every single graph, and it does close them afterwards. It just does not create the files.
|
b2user |
Posted - 08/24/2005 : 10:26:31 AM Hi,
the script now seems to work, and there is no error message, neither while compiling nor while executing the function. The graph of the last y-coloumn stays open in the end. Yet, there are no files created. I changed the directory, and whether it exists or not, there are no files created and no error message. I also tried the image export part of the example script automation.c and exchanged it with the line BOOL bRet = export_page_to_image(strImagePath, strFormat, gpg, nWidth, nHeight, nBitsPerPixel); The result was the same: no error, no image files.
Thank you very much for your help.
|
easwar |
Posted - 08/23/2005 : 09:28:26 AM Hi,
The reason for that error is the following line is missing from your OC file: #include <Origin.h>
You could simply do the following to avoid this in the future, when trying code pasted in the forum: 1> Open code builder and use File->New to create a new OC file. This file will then be created using a template that has the #include line already present 2> Copy-paste the code from forum into this new file and then compile and link
Once you have compiled and linked, then you can go to the script window in Origin (Origin menu Window->Script Window) and type the name of the function as the script command and then hit Enter, so in this case: export_ycols_to_gif()
Easwar OriginLab
|
b2user |
Posted - 08/23/2005 : 07:50:03 AM Thank you very much for the code!
unfortunately compiling it returns the following errors:
\\win.desy.de\home\sendr\My Documents\OriginCode.c(3) :Error, Member's access requires struct/class type. \\win.desy.de\home\sendr\My Documents\OriginCode.c(1) :Error, error(s) found in compiling method \\win.desy.de\home\sendr\My Documents\OriginCode.c(3) :Error, Member's access requires struct/class type. \\win.desy.de\home\sendr\My Documents\OriginCode.c(3) :Error, general compile error \\win.desy.de\home\sendr\My Documents\OriginCode.c(1) :Error, error(s) found in compiling function export_ycols_to_gif
Compiling errors found, linking cannot start!
Would you know what the problem could be?
|
easwar |
Posted - 08/22/2005 : 10:09:26 AM Hi,
You could try the OC function pasted below:
Easwar OriginLab
void export_ycols_to_gif() { Worksheet wks = Project.ActiveLayer(); if( wks ) { // Create graph page GraphPage gpg; // Use Origin default template // You can replace with your custom template gpg.Create("Origin"); // Assume graph has just one layer // You can change to deal with more than one layer GraphLayer gly = gpg.Layers(0); // Loop thru all columns of the wks and move // one at a time into graph and export int nCols = wks.GetNumCols(); for(int icol = 1; icol < nCols; icol++) { // Proceed if type Y if( OKDATAOBJ_DESIGNATION_Y == wks.Columns(icol).GetType() ) { // Remove current data plot from graph layer gly.RemovePlot(0); // Now add current Y col as data plot and rescale Curve crv(wks, icol); gly.AddPlot(crv); gly.Rescale(); // Export to GIF string strFormat = "GIF"; // Width in pixels - change as desired int nWidth = 1024; // Get page properties and set height appropriately to // maintain aspect ratio int nHeight = (int) (nWidth * gpg.Dimension.Height.dVal / gpg.Dimension.Width.dVal); // Bits per pixel int nBitsPerPixel = 8; // Set export file path to be in the User Files folder - change as desired string strDatasetName = wks.GetPage().GetName() + "_" + wks.Columns(icol).GetName(); string strImagePath = GetAppPath() + strDatasetName + ".GIF"; printf("Column %s exported to file: %s\n", strDatasetName, strImagePath); // Call function to export page with desired settings BOOL bRet = export_page_to_image(strImagePath, strFormat, gpg, nWidth, nHeight, nBitsPerPixel); // Report on error if( !bRet ) printf("Failed to export graph for column: %s\n", strDatasetName); } } } }
|
b2user |
Posted - 08/22/2005 : 04:20:16 AM What would that code look like? Sorry I am not too good at programming.
Thanks a lot for your help.
|
easwar |
Posted - 08/19/2005 : 11:18:06 AM Hi,
There is currently no tool in the GUI that you can use to quickly do this. However this should be easy to do programmatically using LabTalk script or Origin C code.
You could create one graph manually, set it to the formatting you desire, then save that as a template. Then programmatically you can open that template, plot one dataset, export to GIF, then replace with the next dataset, export to GIF etc. Or create separate graphs for each Y column if you desire to keep all the graph windows in an Origin project.
Easwar OriginLab
|
|
|