Author |
Topic  |
|
cab0008
25 Posts |
Posted - 06/29/2011 : 5:37:27 PM
|
Hello everyone,
I was wondering if anyone knew of any good function to use such as Project.open but gave the ability to have two projects open at the same time. The reason I would like to do this is to transfer data to and from different projects using code similar to an import, but with the extra capability of full data manipulation over the projects. The code I have written so far is shown below, but my hope is to add to it so that in the long run it will take several different bits of datasets and combine them in various ways in the main "Combined" project and then create plots of the data to export for presentations. This is what I have so far:
void Combine() { string strCombineFile; string strPathToProject; StringArray strOPJpaths,strFiletypes; strFiletypes.SetSize(1); strFiletypes[0]="[ORIGIN PROJECTS]*.opj"; //save Compilation file to be created if(0==get_saveas_box_by_file_group(strCombineFile,"Origin", "SaveFileAs")) printf("User selected cancel"); else { bool bOK = Project.ActiveFolder().SaveAsProject(strCombineFile, SFC_INCLUDE_SUBFOLDERS | SFC_INCLUDE_ATTACHED_FILES); out_str( "Files Saved as :\n" + strCombineFile ); } //gather data from multiple files int NumFiles = GetMultiOpenBox(strOPJpaths,strFiletypes, NULL, NULL, "Select Files for Comination", false); if(NumFiles>0) { //open Comined destination file and create worksheet Project.Open(strCombineFile); WorksheetPage wpCombGreen; wpCombGreen.Create("origin"); wpCombGreen.SetName("DATA532"); Worksheet wksCombGreen; wksCombGreen.Create("Origin"); //put X dataset into Combined Project Dataset dsXGreen; dsXGreen.Attach(wksCombGreen,0); Project.Save(strCombineFile); Project.Open(strOPJpaths[0]); Worksheet wksToCopyGreen("[DATA532]Sheet1"); vector vToCopyGreen(wksToCopyGreen.Columns(1),0,wksToCopyGreen.GetNumRows()-1); Project.Save(strOPJpaths[0]); Project.Open(strCombineFile); dsXGreen = vToCopyGreen; Project.Save(strCombineFile); //open all files and place data into destination for(int i=0; i<NumFiles; i++) { strPathToProject=strOPJpaths[i]; Project.Open(strPathToProject); Worksheet wksToCopyGreen("[DATA532]Sheet1"); vector vToCopyGreen(wksToCopyGreen.Columns(4),0,wksToCopyGreen.GetNumRows()-1); Dataset dsYCombGreen; dsYCombGreen.Attach(wksCombGreen,i); dsYCombGreen = vToCopyGreen; Project.Save(strPathToProject); } Project.Save(strCombineFile); } }
I know this may not be the optimal way to write this but I hope it's at least somewhat in the right direction. Any help with this is greatly appreciated.
Origin Ver. and Service Release (Select Help-->About Origin): Operating System: |
|
Penn
China
644 Posts |
Posted - 06/30/2011 : 02:20:26 AM
|
Hi,
Origin cannot open two projects at the same time. However, you can use the Project.Open() method to append other projects as folders in the current opened project. In your code, you just copy some column data from selected projects to the specified project. To get the data in project, you need to open/append the project first. So, you have gotten the right direction.
Penn |
 |
|
|
Topic  |
|
|
|