Here is an example of a C++ function using pass by reference (non-const pointer arguments): vtkMRMLAnnotationsROINode::GetXYZ(double point).
How do I call this function in Python, i.e. pass an array as argument? With no arguments,
node.GetXYZ() gives TypeError: GetXYZ() takes exactly 1 argument (0 given).
you have to first create a list array. For example.
# create annotation ROI MRML node
roi = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLAnnotationROINode")
# interact with it in the application.. move it around then to retrieve the center of the annotation ROI
point = [0., 0., 0.]
Thank you, this was very helpful for me! It should be some tip for this on the wiki - how to emulate C++ calls through Python - because the C++ API is the only way I know how to do Python scripting.
This page describes how to translate C++ API to Python: Slicer API — 3D Slicer documentation
Some additional useful tips: Python FAQ — 3D Slicer documentation