How to get line markup in real time?

I want to mark a certain section of blood vessels with some attribute. I thought I could draw line by Markup line widget to get the position of vessels. And read some value of attribues from ComboBox. Finally show the result to table viewer and can save the table with csv format. Some questions occured to me:

  1. How can I get Line Markup in real time? That’s means, if I draw a line in current data view, the coordinates of line’s two points can send to table viewer in time.
  2. How can I save the table data with csv format from table viewer ?

Many thanks.

  1. Add an observer to the markup node
    Markup node events:
  2. Get table model:
lm =
tw = lm.tableWidget(0)
tv = tw.tableView()
model = tv.tableModel()

Output to csv:


Thank you. @adamrankin
Follow your first advice, I add an observer(slicer.vtkMRMLMarkupsNode.PointModifiedEvent) to a vtkMRMLMarkupsLineNode. This can get Line’s two points position when draw a new line in the viewer. But this seem to only can get one line, and I want to get the newly drawn line continuously. Can I add an observer to a volume node that observe whether new vtkMRMLMarkupsLineNode is creating, and this will create a markup folder that contain all markup line node? And also all new LineNode is belong to the volume data, When I switch to another volume node, the observer will switch to a new markup folder.

About table, I found that 3D Slicer supports vtkMRMLTableNode. I realize that can solve my problem. Table can show in the viewer, and I can utilize the data node management in Slicer. There are new problems. How can I bind the table node to the markup folder mentioned above? This means that the table node will be updated when the makup folder changes.

Do you have any suggestions on these questions? Looking forward to your reply.