# Python automation of 'constrain to model' for markups curve

**URL:** <https://discourse.slicer.org/t/python-automation-of-constrain-to-model-for-markups-curve/31768>\
**Category:** Development\
**Tags:** markups\
**Created:** [September 18, 2023, 5:42am UTC](https://discourse.slicer.org/t/python-automation-of-constrain-to-model-for-markups-curve/31768 "2023-09-18T05:42:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Zeyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jeff_zeyl/32/70056_2.png) [@Jeff\_Zeyl](https://discourse.slicer.org/u/Jeff_Zeyl)\
**Post date:** [September 18, 2023, 5:42am UTC](https://discourse.slicer.org/t/python-automation-of-constrain-to-model-for-markups-curve/31768/1 "2023-09-18T05:42:33Z")

</div>

I would like to automate the ‘constrain to model’ setting for a markup curve node using python. I have found the c++ function ConstrainPointsToSurface() in the markup curves documentation, with the following parameters:

originalPoints The points to constrain. (vtkpoints)  
normalVectors The normals for the originalPoints. (vtkpoints)  
surfacePolydata The surface to constrain to. (vtkpolydata)  
[out] surfacePoints The points data structure to put the constrained points in. (vtkpoints)  
maximumSearchRadiusTolerance Maximum distance a point can be constrained, specified as a percentage of the model’s bounding box diagonal in world coordinate system. Valid range for this is 0 to 1.

Is the following the correct way to interpret these parameters, and how to access them (in brackets)?  
-originalPoints refers to model points (i.e. modelnode.GetPolyData().GetPoints())  
-normalVectors refers to model normals (i.e. modelnode.GetPolyData().GetPointData().GetNormals()) returns vtkfloatarray\*  
-surface polydata refers to the model polydata (i.e. modelnode.GetPolyData()  
-surfacePoints refers to any vtk points object to hold the new data (e.g. out = vtk.vtkPointData())

If that is correct I guess my next question would be how to get the normals in the vtkpoints format rather than as a vtkfloatarray

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 18, 2023, 1:42pm UTC](https://discourse.slicer.org/t/python-automation-of-constrain-to-model-for-markups-curve/31768/2 "2023-09-18T13:42:33Z")

</div>

You can use a higher-level API for this:

```python
someMarkupsNode.SetAndObserveSurfaceConstraintNode(someModelNode)

```
