Unable to add scalars to `vtkMRMLMarkupsCurveNode`

Hi,

I’m trying to create scalars and add it to the vtkMRMLMarkupsCurveNode. Then I go to the Markups module and I cant find any scalars except PedigreeIDs. Probably I do something wrong… here is the script I use:

# Create random numpy array to use as input
import numpy as np
pointPositions = np.random.uniform(-10,10,size=[4,3])

# Create curve from numpy array
curveNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsCurveNode")
slicer.util.updateMarkupsControlPointsFromArray(curveNode, pointPositions)

# Create scalars
scalars = vtk.vtkDoubleArray()
scalars.SetName('MyScalars')
scalars.InsertNextValue(0)
scalars.InsertNextValue(1)
scalars.InsertNextValue(-1)
scalars.InsertNextValue(3)

# Add scalars to curve node
curveNode.GetCurve().GetPointData().SetScalars(scalars)

It seems that scalars in markups are prette tricky.

First of all the number of ControlPoints in markups doesn’t match the number of points of inner poly data object. For example in my case if I have only 4 ControlPoints then I can see that poly data has 31 points.

The next thing is that I was able to add scalars only after copying PedigreeIDs array to my array (using ShallowCopy or DeepCopy) and then adding my array to the polyData’s points data :

# Create random numpy array to use as input
import numpy as np
pointPositions = np.random.uniform(-10,10,size=[4,3])

# Create curve from numpy array
curveNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsCurveNode")
slicer.util.updateMarkupsControlPointsFromArray(curveNode, pointPositions)

# Get pedigree array
p=curveNode.GetCurve().GetPointData().GetArray('PedigreeIDs')

# Create scalars
np_scalars = np.random.uniform(-10,10,size=curveNode.GetCurve().GetNumberOfPoints())

scalars = vtk.vtkDoubleArray()
scalars.SetName('MyScalars')
scalars.SetVoidArray(np_scalars, np_scalars.size, 1)

# Copy from pedigree to scalars
p.ShallowCopy(scalars)	# or use DeppCopy()

# Add scalars to curve node
curveNode.GetCurve().GetPointData().SetScalars(scalars)

And the last thing is that my scalars are gone right after I do some manipulations with ControlPoints for example moving a single point. The PedigreeIDs array replaces my scalars then.

It seems that even this solution doesn’t work anymore.
If somebody knows a reason please share