Help in programming

Hi,

I would like to get position of a fiducial markup and add it to a variables.

I try this way, but I get ‘none’ for result. There are exist a fiducial.

self.Incus = slicer.qMRMLNodeComboBox()
self.Incus.nodeTypes = [“vtkMRMLMarkupsFiducialNode”]
self.point = self.Incus.currentNode()
pos = [0.0, 0.0, 0.0]
print(self.point.GetNthFiducialPosition(0,pos))

result: None

when I printed only self.point it return all data of the fiducial

Best regards!
Bence

you can access a repository of codes in here, there’s a line of code that can help you:
something like this: fidList.GetNthFiducialWorldCoordinates(0,world)

Szia Bence,

Your print statement prints out the return value of the function. But GetNthFiducialPosition does not return anything, it puts the result in the argument array, in your case pos.
So if you do print(pos) after the GetNthFiducialPosition call, you’ll see the coordinates.

Oooohh, thank you very very much!!! :blush:

And how can I get positions of LineMarkup’s control point?
GetControlPoints() doesn’t work with “vtkMRMLMarkupsLineNode” .

GetControlPoints is not a Python enabled function. You need to use GetNthControlPointPosition. I think it owuld be useful if you checked out the API. Then you’ll see what you can use. Slicer: vtkMRMLMarkupsNode Class Reference

The most convenient way for getting all the control positions in Python is the slicer.util.arrayFromMarkupsControlPointData function.