2.7.9 expGraph
Menu Information
File : Export Graphs (Advanced)
(When Graph window is active)
Brief Information
Export graphs as raster or vector files
Command Line Usage
1. expGraph type:=jpg path:= "c:\image";
2. expGraph type:=bmp path:= "<User Files Folder>" tr1.width:=300 tr1.unit:=2;
3. expGraph pages:=graph2 type:=psd path:= "<Project Folder><PE Path>" tr1.width:=50 tr1.unit:=3;
4. expGraph type:=pdf overwrite:=rename export:=specified pages:=2!; //sheet range (index)
5. expGraph type:=png filename:="<long name>" export:=specified pages:=col(A)[3]; // cell range
6. expGraph -theme "5 Inch Width" type:=eps path:= "c:\image";
7. expGraph type:=eps path:= "c:\image" tr.OpenGLGraph.AntiAlias:=2;
8. expgraph -t <book> path:="c:\test" tr1.Unit:=2 tr1.Width:=600;
X-Function Execution Options
Please refer to the page for additional option switches when accessing the x-function from script
Variables
Display Name
|
Variable Name
|
I/O and Type
|
Default Value
|
Description
|
Image Type
|
type
|
Input
int
|
eps
|
The exported image type for the file. The default option is Encapsulated Postscript (*.eps).
Option list:
- Adobe Illustrator, vector format
- Note: AI option is hidden from Origin 2017. To export graph as AI, set @HAI=0 first. Refer to system variable list for details.
- Bitmap, raster format
- Computer Graphics Metafile, vector format, note that this format is not supported in 64-bit version
- AutoCAD Drawing Interchange, vector format, note that this format is not supported in 64-bit version
- Enhanced Metafile, vector format
- Encapsulated PostScript, vector format
- Graphics Image Format, raster format
- JPEG, Joint Photographic Experts Group, raster format
- Zsoft PC Paintbrush Bitmap, raster format
- Portable Document Format, vector format
- Portable Network Graphics, raster format
- Adobe PhotoShop, raster format
- Truevision Targa, raster format
- TIFF, Tag Image File, raster format
- Windows Metafile, vector format
- Scalable Vector Graphics, vector format
|
Select Graph(s)
|
export
|
Input
int
|
page
|
Use this option to select the page(s) to be exported. The default option is Active Page.
Option list:
- the active graph page will be exported
- folder:All in Active Folder
- All the graph pages in active folder of the project (see this in Project Explorer) will be exported. The pages in subfolders will not be included. Hidden pages will also be included, while embedded graph pages in worksheet will not be included.
- recursive:All in Active Folder (Recursive)
- All the graph pages in active folder of the project (see this in Project Explorer) will be exported. The subfolders will be recursively included.
- open:All in Active Folder (Open)
- All the opened (not hidden) pages in active folder of the project will be exported.
- embed:All in Active Folder (Include Embedded)
- All the graph pages in active folder of the project (see this in Project Explorer) will be exported. Both hidden pages and embedded pages will be included.
- All the graph pages in the project will be exported. Hidden graph pages will be included while embedded pages will not.
- Other than the options above. Specify the pages in Graph Page below.
|
Graph Page
|
pages
|
Input
string
|
<active>
|
Select the graph pages in the project to be exported. Click the browse button to open Graph Browser to select the graph pages. The graph pages to be exported can be specified using cell ranges or sheet ranges to accommodate export of embedded graphs. See examples in Command Line Usage.
|
Export as multi-page PDF file
|
multipage
|
Input
int
|
0
|
Export the multiple graph pages to one PDF file with multi-pages.
|
File Name(s)
|
filename
|
Input
string
|
|
The name(s) for the exported image file(s).
- <Long Name>: use the long name of the graph page as file name.
- <Short Name>: use the short name of the graph page as file name.
- Graph ##: use Graph + index (in the same order as listed in GraphPage) as file name.
- Graph<pound>#: use "graph# + index" (in the same order as listed in the Graph Page list) and character "#"(represented by <pound>) combined together as file name.
Note:
- File Name supports keyword combination, such as <longname>-multi, the long name of the graph and the string -multi will be used as the export file name.
- <pound>, representing the character "#", can also be used without combining with graph index. For example, Set File Name(s) as Graph<pound>2 then the display graph name would be Graph#2.
|
Path
|
path
|
Input
string
|
|
The file path to save the exported image file(s).
|
Overwrite Existing
|
overwrite
|
Input
int
|
ask
|
To specify if the existing file(s) in the path should be overwritten. Ask is the default option.
Option list:
- Auto rename with enumeration
- Replace the existing file(s)
- Skip the existing file(s)
- Pop up message box to ask if overwrite or not.
|
Graph Theme
|
theme
|
Input
string
|
|
Graph theme which is used to applied on the exported pages
Any Theme saved in the theme organizer can be used with this variable.
|
Use Preference Options
|
sysopts
|
Input
int
|
1
|
Whether to use Page settings from Preference Option dialog.
Default is used.
This is not visible in GUI and only used in script.
|
Export Settings
|
tr
|
Input
TreeNode
|
<unassigned>
|
Page settings for export
|
Keep Original Size
|
keepsize
|
Input
int
|
0
|
Whether to keep original graph size.
Default is keep.
This is not visible in GUI and only used in script.
|
Image Size
|
tr1
|
Input
TreeNode
|
<unassigned>
|
Set the size for the exported image.
|
Image Settings
|
tr2
|
Input
TreeNode
|
<unassigned>
|
Set properties of the exported image.
|
Description
This X-Function exports the graph(s) in Origin to various image file(s). It has a graphical user interface (GUI) with previews. In the left panel, there are settings for the functions. In the right, there are two tabs, one is Image, which displays a preview for the exported image, and the other is Graph, which displays a cloned graph page for the source page to be exported.
Supported Formats
Totally 14 image file formats are supported for exporting to image file. These files fall into two categories:
- Raster Formats define a fixed size array of (rows and columns) of colors. These formats take proportionately larger file space for increased detail and do not scale well. Raster file size is a function of resolution and color density. Raster formats are best used when you must reproduce graphs and layout pages with much detail and many colors, and where scalability is not a concern.
- Vector formats contain instructions on how to draw an image and may contain additional information about size and resolution. These formats scale well (within limits), but must be interpreted by a target application, and this is subject to error. File size is proportional to the complexity of the image. Vector formats are best used for graphs and layout pages with little detail and few colors, or for applications where scalability is needed.
The supported formats have been listed for the variable Image Type in the Variables section.
Details on Some Dialog Options
- Please see Export Settings for more details.
-
- Please see Image Size for more details.
-
- Please see Image Settings for more details.
Examples
In this example, we will show how to create the same sub-folder hierarchy according to project folder structure, and export graphs into their own folders named after graph window long name.
Solution for Origin 2017 and later:
Note that predefined path such as <Project Folder><PE Path> was introduced in Origin 2017 to easily export graphs according to project folders in an opj file.
doc -e P
{
if(page.IsEmbedded==0&&exist(%H)!=11) //Skip over any embedded graphs or Layout windows
{
window -a %H; //Activate graph window
expGraph type:=jpg filename:="<long name>" path:="<Project Folder><PE Path>" theme:=<Original> tr.Margin:=2;
}
}
Solution for Origin 2016 and later:
Note that string register %@P is only introduced since Origin 2016 SR2 which denotes the full Project Explorer path of the active folder.
doc -e P
{
if(page.IsEmbedded==0&&exist(%H)!=11) //Skip over any embedded graphs or Layout windows
{
window -a %H; //Activate graph window
string a$=%X; //Get windows path of saved project
string b$=%@P; //Get graph project path
b.Replace("/","\"); //Correct path notation
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;
}
}
Solution for Origin 2015 and earlier:
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 length
cs=cs+2; //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;
%A=graph_fullPath$;
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$+graph_Path$; //Concatenate above strings to create export folder;
path.Replace("/","\");
expGraph type:=jpg filename:="<long name>" path:=path$ theme:=<Original> tr.Margin:=2;
};
}
Related X-Functions
expImage, expWks
Keywords:publishing
|