# Create a markups plane programmatically

**URL:** <https://discourse.slicer.org/t/create-a-markups-plane-programmatically/14491>\
**Category:** Development\
**Created:** [November 8, 2020, 4:12pm UTC](https://discourse.slicer.org/t/create-a-markups-plane-programmatically/14491 "2020-11-08T16:12:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 8, 2020, 4:12pm UTC](https://discourse.slicer.org/t/create-a-markups-plane-programmatically/14491/1 "2020-11-08T16:12:14Z")

</div>

I don’t know how to create a markups plane through code. I tried the following with no success:

> A = slicer.vtkMRMLMarkupsPlaneNode()  
> A.SetOrigin([0,0,0])  
> A.SetNormal([0,0,1])  
> A.SetAxes([1,0,0],[0,1,0],[0,0,1])  
> A.UpdateScene(slicer.mrmlScene)

Expected behaviour: A new plane is shown on the 3D view and on the Markups Node list.

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [November 8, 2020, 4:27pm UTC](https://discourse.slicer.org/t/create-a-markups-plane-programmatically/14491/2 "2020-11-08T16:27:28Z")

</div>

You need to add the node to the scene first. Try:

```auto
A = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsPlaneNode")
A.SetOrigin([0,0,0])
A.SetNormal([0,0,1])
A.SetAxes([1,0,0],[0,1,0],[0,0,1])

```

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 9, 2020, 2:06am UTC](https://discourse.slicer.org/t/create-a-markups-plane-programmatically/14491/3 "2020-11-09T02:06:44Z")

</div>

In math only with an point and a normal vector it is possible to define a plane. So why do we use SetAxes function and what does it does?  
Then, I have a transform linked to the PlaneToWorldMatrix of the plane and it’s applied to a model. Why when I execute these lines the position of the model changes for the same normal vector?:

> plane.SetNormal([0,0,1])#  
> plane.SetNormal([0,1,0])  
> plane.SetNormal([1,0,0])  
> plane.SetNormal([0,0,1])#  
> plane.SetNormal([0,1,0])  
> plane.SetNormal([1,0,0])

How does the SetNormal function works?
