How to make segments from vtkMRMLModelNode by code

Hi,
I have some ModelNodes from .vtk files attacked to lineartransforms.
With this code i get new segments for each model in segmentation but with wrong location.
How to fix segments position?

name = model.GetName()
abstransform = model.GetParentTransformNode().GetTransformFromParent()
applyTransform = vtk.vtkTransformPolyDataFilter()
applyTransform.SetTransform(abstransform )
applyTransform.SetInputData(model.GetPolyData())
applyTransform.Update()
surface = applyTransform.GetOutput()
# Remove point arrays to make sure they don’t affect display color
while surface.GetPointData().GetNumberOfArrays()>0:
surface.GetPointData().RemoveArray(0)
segmentation.AddSegmentFromClosedSurfaceRepresentation(surface, name, [1,1,1])

Thanks on advance!

I don’t understand exactly what you are trying to do but would hardening the transform help?

Take a look at this page. For an example of how to harden the transform using python.

Otherwise perhaps you have to also put the new segments in the linear transform so they also end up in the same location as the models?

1 Like

If you load the .vtk files as models (using File / Add data) do they appear at the correct position?

1 Like

No, they appear but in wrong position.

I tried it before, but individual segments are not transformable nodes.
To harden model transform works right.
Thanks so much.

1 Like