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 for Programming
 Forum for Origin C
 A question with using X-function in Origin C

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
wufengseu Posted - 01/19/2008 : 03:54:37 AM
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!
8   L A T E S T    R E P L I E S    (Newest First)
larry_lan Posted - 03/29/2010 : 04:37:43 AM
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
altertoby Posted - 03/27/2010 : 12:21:27 PM
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?
wufengseu Posted - 02/25/2008 : 08:31:15 AM
Hi Deanna,

great thanks for you perfect solution.
Deanna Posted - 01/28/2008 : 05:02:58 AM
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
cpyang Posted - 01/24/2008 : 4:44:36 PM
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


easwar Posted - 01/24/2008 : 3:55:34 PM
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

wufengseu Posted - 01/22/2008 : 06:43:14 AM
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
Deanna Posted - 01/20/2008 : 8:40:27 PM
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

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