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
 All Forums
 Origin Forum
 Origin Forum
 Exporting graphs according to project folders

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jacorem Posted - 05/09/2016 : 05:45:02 AM
Hi!
Let's say that in my project I have two folders, folderA and folderB, and in both folders I have a graph (graphA and graphB).
I want to export both graphs as picture (jpeg) but in two subfolder so to obtain like
-<project folder>/graphs/folderA/graphA.jpg and
-<project folder>/graphs/folderB/graphB.jpg.
I tried to play a bit with the export window fields, but I couldn't managed to do so. Anyone know if is possible and how, or if I have to export every single project folder manualy?

Origin Ver. and Service Release: OriginPro 2015 (64bit) Sr2, b9.2.272 (accademic)
Operating System: Windows 10 64 bit

Thanks,

Jacopo Remondina,
University of Milano-Bicocca,
Department of Material Science
7   L A T E S T    R E P L I E S    (Newest First)
meili_yang Posted - 05/12/2016 : 2:15:00 PM
Hi Jacorem,

Thanks very much your reply. However I got command error not sure if you see that when you run. Seems there is a duplicated slash when define path$, and delete the slash after "graph" and replace "/" with "\" makes it work for me.

pe_cd /; //move to root directory
string root_folder$;
pe_path path:=root_folder$; //get directory path
//type root_folder$;
int cs=%[root_folder$]; //get path lenght
cs=cs+2; //I needed to add 2(probably due to spaces and similar) 
//cs=;
doc -e P //loop over all graph-like objects
{
	if(page.IsEmbedded==0&&exist(%H)!=11)  //Skip over any embedded graphs or Layout windows
	{
		string proj_path$=%X; //Get windows path of saved project;
		//type "the project path is:"+proj_path$;
		window -a %H;	
		string graph_fullPath$;
		pe_path path:=graph_fullPath$; //Get graph project explorer path;
		//type "provissorial path:"+graph_fullPath$;
		%A=graph_fullPath$;
		//type "what I don't need:"+%[%A,cs];
		string graph_path$=%[%A,>cs]; //remove the root folder name from path
		//type "the graph path is:"+graph_path$;
		//type "graph title is:"+%H;
		string path$=proj_path$+"/graphs"+graph_Path$; //Concatenate above strings to create export folder;
		path.Replace("/","\");
		expGraph type:=jpg filename:="<long name>" path:=path$ theme:=<Original> tr.Margin:=2;
	};
}


The graphs are all exported under "graphs" folder which is user defined string in the code. Otherwise in order to name export folder after project name, just modify the concatenate code as following, and could also comment the above rows where to delete project name from graph_fullPath$.

string path$=proj_path$+graph_fullPath$;

Nice work overall! Thanks again.


quote:
Originally posted by jacorem

I modify a bit Meili code to produce what I need, and this is the final result:
pe_cd /; //move to root directory
string root_folder$;
pe_path path:=root_folder$; //get directory path
//type root_folder$;
int cs=%[root_folder$]; //get path lenght
cs=cs+2; //I needed to add 2(probably due to spaces and similar) 
//cs=;
doc -e P //loop over all graph-like objects
{
	if(page.IsEmbedded==0&&exist(%H)!=11)  //Skip over any embedded graphs or Layout windows
	{
		string proj_path$=%X; //Get windows path of saved project;
		//type "the project path is:"+proj_path$;
		window -a %H;	
		string graph_fullPath$;
		pe_path path:=graph_fullPath$; //Get graph project explorer path;
		//type "provissorial path:"+graph_fullPath$;
		%A=graph_fullPath$;
		//type "what I don't need:"+%[%A,cs];
		string graph_path$=%[%A,>cs]; //remove the root folder name from path
		//type "the graph path is:"+graph_path$;
		//type "graph title is:"+%H;
		string path$=proj_path$+"/graphs/"+graph_Path$; //Concatenate above strings to create export folder path 
		expGraph type:=jpg filename:="<long name>" path:=path$ theme:=<Original> tr.Margin:=2;
	};
}





Meili
OriginLab Tech Support
jacorem Posted - 05/12/2016 : 11:49:36 AM
I modify a bit Meili code to produce what I need, and this is the final result:
pe_cd /; //move to root directory
string root_folder$;
pe_path path:=root_folder$; //get directory path
//type root_folder$;
int cs=%[root_folder$]; //get path lenght
cs=cs+2; //I needed to add 2(probably due to spaces and similar) 
//cs=;
doc -e P //loop over all graph-like objects
{
	if(page.IsEmbedded==0&&exist(%H)!=11)  //Skip over any embedded graphs or Layout windows
	{
		string proj_path$=%X; //Get windows path of saved project;
		//type "the project path is:"+proj_path$;
		window -a %H;	
		string graph_fullPath$;
		pe_path path:=graph_fullPath$; //Get graph project explorer path;
		//type "provissorial path:"+graph_fullPath$;
		%A=graph_fullPath$;
		//type "what I don't need:"+%[%A,cs];
		string graph_path$=%[%A,>cs]; //remove the root folder name from path
		//type "the graph path is:"+graph_path$;
		//type "graph title is:"+%H;
		string path$=proj_path$+"/graphs/"+graph_Path$; //Concatenate above strings to create export folder path 
		expGraph type:=jpg filename:="<long name>" path:=path$ theme:=<Original> tr.Margin:=2;
	};
}


All the "type" commands were used for debugging the code, so I kept them.

N.B. the code work but it take quite a lot, so, if you have lots of folders/graphs, maybe is better to un-comment a "type" line.

Jacopo Remondina,
University of Milano-Bicocca (Italy),
Department of Material Science
meili_yang Posted - 05/12/2016 : 11:24:12 AM
Hi Jacopo,

Just notice you actually have Origin 2015. And the string resistor I used in my codes "%@P" is a new thing we added and only works in Origin 2016. In Origin 2015 there must be some work around to create path for sub-folder, but I think it's more convenient to use %@P to call project path in one string.

Seems you use a site license. Usually you should be able to upgrade to Origin 2016 since most universities keep active maintenance. I would suggest you to install Origin 2016 and get a license from your IT department. You can go to following link to download Origin 2016 installer. http://www.originlab.com/demodownload.aspx


Meili
OriginLab Tech Support
jacorem Posted - 05/12/2016 : 08:30:14 AM
Thanks again Meili;
unfortunatly your script doesn't seems to work (I just tried, but no subfolder were created). Anyway, I think that I can fix it with a bit of work and your initial script. I will post the working version as soon as I will check it.

Jacopo Remondina,
University of Milano-Bicocca (Italy),
Department of Material Science
meili_yang Posted - 05/10/2016 : 2:42:01 PM
Hi Jacorem,

Thanks for your updates. So far it doesn't seem possible to do this from GUI, but could be done by scripts. I wrote an example as in following:

doc -e P
{if(page.IsEmbedded==0&&exist(%H)!=11) //Skip over any embedded graphs or Layout windows
    {
window -a %H;
string a$=%X; //Get windows path of saved project
string b$=%@P; //Get graph project path 
b.Replace("/","\");
i=b.delete(1);
string path$=a$+b$; //Concatenate above strings to create export folder path 
expGraph type:=jpg filename:="<long name>" path:=path$ theme:=<Original> tr.Margin:=2;}}


To run the code, open Script Window from menu Window. Copy and paste above code, highlight all rows and press Enter on keyboard. It will create the same level of sub-folders according to project folder, and graphs will be exported into own folder named after graph window long name.

The key issue to create a correct path string with graph project path. I am using string registers.

String registers: http://www.originlab.com/doc/LabTalk/guide/String-registers

expGraph x-function:
http://www.originlab.com/doc/X-Function/ref/expGraph

Hope it can help.


Meili
OriginLab Tech Support
jacorem Posted - 05/10/2016 : 11:53:47 AM
Thanks Meili for your answer, unfortunatly, I already followed the procedure you have descripted, and my question was exactly about automaticly create the sub-folders (the same I have in my project) and saving the graphs in them.

Jacopo Remondina,
University of Milano-Bicocca (Italy),
Department of Material Science
meili_yang Posted - 05/09/2016 : 4:37:46 PM
Hi Jacorem,

The Export Graphs dialog has an option to export all graphs in the current project, besides graphs within one folder.

With a graph activated, and go to menu File: Export Graphs:Open dialog. The options as I mentioned is under Selected Graph(s).



The exported graph will be named after graph window long name by default and all the graphs will stay in one folder where the path is defined.

I am wondering if you want to export to sub-folders and name the windows folder as in project folder? Something like:
graphA will export to <project folder>\project name\folderA\graphA.jpg

graphB will export to <project folder>\project name\folderB\graphB.jpg?
If so I think you may need to script to do so.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000