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
 Origin Forum
 get data from graph to worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

kist-europe

Germany
Posts

Posted - 12/19/2007 :  11:07:02 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello everyone,

I have drawn a circle with the circle tool in a graph.
How can I get the X,Y coordinate data of every point in the worksheet?

Thank you!
Kist-europe

Mike Buess

USA
3037 Posts

Posted - 12/19/2007 :  12:26:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I suspect you ultimately want the coordinates of the points inside the circle. In that case it would be easiest to upgrade to Origin 7.0 or higher and use the Cluster Tool which does everything for you. (It even draws the circle.) If that's not possible, then here is a hint. The name of the active Y dataset is saved as %C so this script types the coordinates of all points in the active curve to the script window...

get %C -e nrows; // get # points in active curve
loop(ii,1,nrows) {
yy = %C[ii]; // y value at row #i
xx = xvalue(ii,%C); // x value at row #i
type "i=$(ii), x=$(xx), y=$(yy)";
};

Mike Buess
Origin WebRing Member
Go to Top of Page

kist-europe

Germany
Posts

Posted - 01/02/2008 :  06:56:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

I have upgrade the program to Origin 8.0. And I have sucessfully installed the Cluster Tool. But when I want to draw the circle in a graph, it comes out a window names 'Classic script Window'. And it seems that I should program it. It is not like the screem shot under http://www.originlab.com/FileExchange/details.aspx?fid=116
Could you please have a look at it?

Thank you
Go to Top of Page

PeterKunhardt

USA
Posts

Posted - 01/02/2008 :  5:05:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you are looking to draw a circle on a graph and simultaneously put the values of the data points along that circle into a worksheet, there is actually an x-function designed for that specific purpose called "plotellipse." By typing "plotellipse 10 10;" in the script window, you can call Origin to create a circle centered on 0,0 with a diameter of 10. "Plotellipse 5 10;" will create an ellipse with a height of five and a width of ten.

Alternatively, you can code the x-function to have as many data points as you want with something like this:

for(i=1;i<=36;i++)
{
a=i*10;
col(a)[i]=10*cos(a);
col(b)[i]=10*sin(a);
}

This code will write the values of a circle composed of 36 data points directly to a worksheet. You can create the graph from there if you need one.
Go to Top of Page

yuivanov

USA
11 Posts

Posted - 01/04/2008 :  2:16:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Kist-europe
If I understand your need correctly, the following OriginC code would work for you:



void GetTraceData()
{
PolylineGraphObject gr;

// first step - get selected object
gr = Selection.Objects();
if( gr )
{
vector<float> vx;
vector<float> vy;

// get trace points in axis coordinates
if( gr.GetPoints(vx, vy) > 0 )
{
// create new worksheet
Worksheet wks;
wks.Create();
// make sure we have at least two columns in the worksheet
wks.SetSize(-1,2);
// finally put data in
Dataset dsX(wks, 0);
Dataset dsY(wks, 1);
dsX = vx;
dsY = vy;
}
}
}




In order to compile this code
1. Open code builder and create som new *.cpp file (make sure that "Add to workspace" checkbox is checked)
2. Copy the code above and paste it into your file and compile it
3. Draw your circle (or freehand) and select it.
4. In the script window type "GetTraceData" and hit Enter
At that time new worksheet will get created with X and Y data points points in axis units.
Hope this helps.
Yuri
Go to Top of Page

greg

USA
1379 Posts

Posted - 01/15/2008 :  11:29:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here's a script that does what Yuri's C code does:

selection -g A; // grab the name of the selected line object
%M=%H; // Remember this window name
win -t data origin; // Create worksheet for data
%N=%H; // Remember this worksheet name
win -a %M; // Go back to the original window
for(done=0,idx=1;done==0;idx++) {
xval = %A.x$(idx);
yval = %A.y$(idx);
if(xval!=0/0) {
%N!cell(idx,1)=xval;
%N!cell(idx,2)=yval;
}
else
done=1;
}

Since LabTalk does not have a GetPoints( ) method, nor do we know how many points are in the line, I looped through points (object.x1, object.y1, object.x2, object.y2, etc.) until I stopped getting values values (xval == 0/0 == 'missing').

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