# Creating a line between already made mark up points

**URL:** https://discourse.slicer.org/t/creating-a-line-between-already-made-mark-up-points/19648
**Category:** Support
**Created:** [September 13, 2021, 7:01pm UTC](https://discourse.slicer.org/t/creating-a-line-between-already-made-mark-up-points/19648 "2021-09-13T19:01:34Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mohammed\_alshakhas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mohammed_alshakhas/32/10025_2.png) [@mohammed\_alshakhas](https://discourse.slicer.org/u/mohammed_alshakhas)
#### Post date: [September 13, 2021, 7:01pm UTC](https://discourse.slicer.org/t/creating-a-line-between-already-made-mark-up-points/19648/1 "2021-09-13T19:01:34Z")

</div>

I’m trying to draw lines exactly where I placed some markup points

is there a way to define a line or plane according to already placed mark-up points?

thanks

---

<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 13, 2021, 7:08pm UTC](https://discourse.slicer.org/t/creating-a-line-between-already-made-mark-up-points/19648/2 "2021-09-13T19:08:50Z")

</div>

You can copy-paste markup control points from a markups fiducial list to a markups line in Markups module. Select the markups fiducial list, in Control points section select the two control points, hit Ctrl-C to copy them to the clipboard, select the markups line, and hit Ctrl-V to past the control points into the line).

---

<div class="post-metadata">

### Author: ![ImreBarabas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/imrebarabas/32/80109_2.png) [@ImreBarabas](https://discourse.slicer.org/u/ImreBarabas)
#### Post date: [October 26, 2023, 11:00pm UTC](https://discourse.slicer.org/t/creating-a-line-between-already-made-mark-up-points/19648/3 "2023-10-26T23:00:13Z")

</div>

Dear Andras!

Is it possible to make automatic? I mean I have two markup points and get a line between these two points, without Ctrl-C and Ctrl-V?

Thanks a lot,  
Imre

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [October 27, 2023, 2:30am UTC](https://discourse.slicer.org/t/creating-a-line-between-already-made-mark-up-points/19648/4 "2023-10-27T02:30:09Z")

</div>

Thats like three clicks; one to create the empty line markups object, one to copy and one to paste.

Is it too complicated? You can probably do it by scripting it.

---

<div class="post-metadata">

### Author: ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)
#### Post date: [October 27, 2023, 6:37am UTC](https://discourse.slicer.org/t/creating-a-line-between-already-made-mark-up-points/19648/5 "2023-10-27T06:37:01Z")

</div>

Yes, this is easily scriptable. Here is an example function you could paste in the python interactor

```auto
def connectPoints(markupsNode1, markupsNode2):
    '''Simple function which connects the first control
    point of markupsNode1 to the first control point of 
    markupsNode2 with a line'''
    pt1 = markupsNode1.GetNthControlPointPositionWorld(0)
    pt2 = markupsNode2.GetNthControlPointPositionWorld(0)
    newCurveNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLMarkupsCurveNode')
    newCurveNode.AddControlPoint(*pt1)
    newCurveNode.AddControlPoint(*pt2)
    return newCurveNode

```

Then you could use it like this:

```auto
connectingLineNode = connectPoints(getNode('myFirstPoint'), getNode('mySecondPoint'))

```

where you would need to replace ‘myFirstPoint’ and ‘mySecondPoint’ with the names of the markups which contain the two points you want to connect.

---

<div class="post-metadata">

### Author: ![ImreBarabas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/imrebarabas/32/80109_2.png) [@ImreBarabas](https://discourse.slicer.org/u/ImreBarabas)
#### Post date: [October 27, 2023, 6:56am UTC](https://discourse.slicer.org/t/creating-a-line-between-already-made-mark-up-points/19648/6 "2023-10-27T06:56:18Z")

</div>

Dear Mike Bindschadler!

Thank you so much it works!

With best regards,  
Imre
