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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 A question with using X-function in Origin C
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

wufengseu

China
Posts

Posted - 01/19/2008 :  03:54:37 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 8.0
Operating System:Win XP

How can I embed the following code into a function of OC.
expGraph exp:=5
filename:="<Short Name>" //export a graph to disk F.
type:=jpg
path:= F:
tr.Margin := 0.5
tr.Advanced.DPI:=150;

Great thanks!

Deanna

China
Posts

Posted - 01/20/2008 :  8:40:27 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

In XFbase.h (under <Origin 8 program folder>\OriginC\System\), you can find two examples on how to call X-Functions with Origin C:
void Example_1_call_xf_from_OC(int nSize = 25, int nSeed = 77)
and
void Example_2_call_xf_from_OC(int nSize = 25, int nSeed = 77)

Generally, we can use XFBase:SetArg() or XFBase:SetArgs() to set the arguments and then use XFBase:Evaluate() to run the X-Function.

If you have other questions regarding how to call X-Function in OC, you are welcome to post again here or write to tech@originlab.com .

Deanna
OriginLab Technical Services
Go to Top of Page

wufengseu

China
Posts

Posted - 01/22/2008 :  06:43:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
hi,Deanna!

Following you advise,I made some progress:
#include <Origin.h>
////////////////////////////////////////////////////////////////////////////////////

#include <XFbase.h>

void xf_from_OC()
{
string strXFNameToCall = "expPDF";

XFBase xf(strXFNameToCall);
if ( !xf )
{
out_str("Failed to load xfunction.");
return;
}

string fname= "F:\\wf.pdf";
Worksheet iw = "Book1";


// Setting individual argument by name:


if ( !xf.SetArg("iw", iw) )
{
out_str("Failed to set arguments.");
return;
}

if ( !xf.SetArg("fname", fname) )
{
out_str("Failed to set arguments.");
return;
}


if ( !xf.Evaluate() )
{
out_str("Evaluation failed.");
return;
}


while a problem with the method of using "TreeNode" for making Export Settings troubles me.

Its improtant to set the DPI of a graph, which is the real destination I need to reach.





Edited by - wufengseu on 01/23/2008 05:15:03 AM
Go to Top of Page

easwar

USA
1964 Posts

Posted - 01/24/2008 :  3:55:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Apologies for the delay. We will soon post some examples.

The tr.Advanced.DPI that you were looking at is not for the page dpi setting. It is some other advanced setting that affects embedded objects. The page dpi setting is in the tr2 tree for which we need to provide more documentation and examples.

Easwar
OriginLab

Go to Top of Page

cpyang

USA
1406 Posts

Posted - 01/24/2008 :  4:44:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I am afraid this will need to wait for SR2. Currently there is no InvokeMakeTree method, even though there is a InvokeBeforeExecute. I have added tracker 10998 for this.

CP


Go to Top of Page

Deanna

China
Posts

Posted - 01/28/2008 :  05:02:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Wufengseu,

Sorry for a delayed reply.

We plan to implement a function in OC that allows getting trees generated by X-Function in SR2.

For now, we can use LabTalk script to control the DPI of raster formats by using the tr2 tree (Not the tr.Advanced.dpi tree). For example:

expGraph pages:=<active> type:=jpg path:= "c:\test" filename:="abc" tr1.width:=300 tr1.unit:=2 tr2.jpg.DotsPerInch:=100; //Sets DPI to 100


In Origin C functions, we can use the LT_execute funciton to execute Labtalk script so as to perform the exporting.

void test_graph_export()
{
string strCMD = "expGraph pages:=<active> type:=jpg path:= \"c:\\test\" filename:=\"abc\" tr1.width:=300 tr1.unit:=2 tr2.jpg.DotsPerInch:=100";
LT_execute(strCMD);
}


Very sorry for the inconvenience.

Deanna
OriginLab Technical Services
Go to Top of Page

wufengseu

China
Posts

Posted - 02/25/2008 :  08:31:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Deanna,

great thanks for you perfect solution.
Go to Top of Page

altertoby

4 Posts

Posted - 03/27/2010 :  12:21:27 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

I am afraid this will need to wait for SR2. Currently there is no InvokeMakeTree method, even though there is a InvokeBeforeExecute. I have added tracker 10998 for this.

CP



Sorry for answering to this old thread, but I could not find any hint of such a method (even in 8.0 SR 6).
What happen to this tracker?
Go to Top of Page

larry_lan

China
Posts

Posted - 03/29/2010 :  04:37:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
We added a GetXFCreatedTree method for this tracker, which allow user customize X-Function created trees. For example, to set DPI when exporting graph:

#include <Origin.h>
#include <XFbase.h> 

void setDPI()
{
	XFBase xf("expGraph");
	xf.SetArg("type", 7);
	string strPath("c:\\");
	xf.SetArg("path", strPath);
	string strFile("MyImage");
	xf.SetArg("filename", strFile);
	string strPage = "Graph1";
	xf.SetArg("pages", strPage);

	TreeNode tr;
	if( xf.GetXFCreatedTree("tr", tr) )
	{
		tr.Advanced.DPI.nVal = 600;
		out_tree(tr); // Output the tree 
		xf.SetArg("tr", tr);
	} 
	if ( !xf.Evaluate() )
	{
		out_str("Evaluation failed.");
		return;
	}
}

Larry
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000