1 (edited by GraphUser3546 2012-12-23 17:56:34)

Topic: Modifying point series with Python script

Greetings,

I'm learning Python in order to automate some operations on Point Series in Graph. FYI, I have programmed in C++ and LabVIEW in the past, so I'm not totally new to the coding world and object-oriented programming.

I believe I'd need to use the "GetPoint" method to get the current value of data points, apply my operations to the data, then use the "InsertPoint" and "DeletePoint" methods to replace the old data with the new modified one.

So I select my Point Series and check that

type(Graph.Selected)

confirms it's a "Data.TPointSeries"

From there, I should probably use something like :

Graph.Selected.GetPoint(self, *args)

to get the point values, but looking at your SWIG-generated ".py" code, I can't figure out what are the arguments that the GetPoint expects. The same interrogation applies to the InsertPoint and DeletePoint methods for my needs.

Maybe I'm wrong all the way too smile Could you please guide me a bit in extracting data from a Point Series and modifying it through the Python interface?

Thank you very much!

EDIT: just a sample script adding 1 to x and 2 to y coordinates of all points in a series could do the trick too if it's easier for you.

Re: Modifying point series with Python script

You can use Graph.Selected.Points to access the points as a list. Every entry will be a tuple with a (x,y) coordinate. You can add, remove and change points as with any Python list. Here is an example that adds 1 to every x-coordinate and 2 to every y-coordinate:

P = Graph.Selected.Points
for i in range(len(P)):
  P[i] = (P[i][0]+1, P[i][1]+2)

Re: Modifying point series with Python script

Thank you very much!

I was using the dir(Graph.Selected) and it didn't show the "Points" function, hence my being puzzled. Well if it's a simple list of tuple, I'll be playing with them any way I want now.

A grateful Graph User.

Re: Modifying point series with Python script

Unfortunately dir does not always show everything. You may therefore want to check the documentation, which is also installed with Graph: http://www.padowan.dk/doc/PluginDoc/Gra … l#id505437

Re: Modifying point series with Python script

ah! that's what I was searching for! Thanks!