Print the point's RAS in real time

I creat a point F, I want to print the point’s RAS position in python console,in real-time,when I move it.

Anyone can tell me how to write the script?

I write it as like this,it doesn’t work:

F_Node=getNode('F')

def printRAS(Node,Event=None):
      print(Node.GetNthFiducialPosition(0, position))

Tag = F_Node.AddObserver(slicer.vtkMRMLMarkupsNode.PointModifiedEvent,  printRAS)

If you try calling your printRAS function with the node as a parameter you can see position is not defined. Also if you do use help(F_node.GetNthFiducialPosition) you can see that GetNthFiducialPosition is deprecated and you should use GetNthControlPointPosition instead.

So the better code would be:

def printRAS(Node, Event=None):
    print(Node.GetNthControlPointPosition(0))

F_Node.AddObserver(slicer.vtkMRMLMarkupsNode.PointModifiedEvent, printRAS)
1 Like