Hi,
In Origin 8.1, you can use method GetGraphPoints::GetData to get plot index of the selected point, then get data range from the plot, and finally get the book name and sheet name.
void test_GetData()
{
GraphLayer gl = Project.GraphPages(-1).Layers(-1);
if(!gl)
return;
int nNumPoints = 2;
GetGraphPoints sp;
sp.SetFollowData(true, -1); // not following any data plot
sp.GetPoints(nNumPoints, gl); // select two points from graph layer
vector vx, vy;
vector<int> vnIndices;
vector<int> vnDataPlotIndices;
sp.GetData(vx, vy, vnIndices, vnDataPlotIndices); // get the selected data
for(int iIndex=0; iIndex<vnIndices.GetSize(); iIndex++)
{
out_str("The result of GetPoints:");
DataPlot dp = gl.DataPlots(vnDataPlotIndices[iIndex]); // get the plot
if(!dp)
continue;
DataRange dr;
dp.GetDataRange(dr); // get data range from plot
string strBook;
string strSheet;
dr.GetBookSheet(strBook, strSheet, 0); // get book name and sheet name
printf("Point %d: X=%f, Y=%f, Index=%d, Book=%s, Sheet=%s\n", iIndex+1, vx[iIndex], vy[iIndex], vnIndices[iIndex], strBook, strSheet);
}
}
If you are using Origin 8, you can download a demo version of Origin 8.1 to have a try.
Penn
OriginLab Technical Services