# Create/draw line markup from scripted module

**URL:** <https://discourse.slicer.org/t/create-draw-line-markup-from-scripted-module/23113>\
**Category:** Support\
**Tags:** module, markups\
**Created:** [April 25, 2022, 11:48am UTC](https://discourse.slicer.org/t/create-draw-line-markup-from-scripted-module/23113 "2022-04-25T11:48:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![llafitte007](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@llafitte007](https://discourse.slicer.org/u/llafitte007)\
**Post date:** [April 25, 2022, 11:48am UTC](https://discourse.slicer.org/t/create-draw-line-markup-from-scripted-module/23113/1 "2022-04-25T11:48:21Z")

</div>

Hello Slicer Community,

I’m new to the Slicer world so I apologize in advance if I make any mistakes.

I am creating a small module that allows you to manage needles on images (import, visual control, modification, export). Basically, a needle is a line markup.

here a preview of the module

 ![Capture d’écran de 2022-04-25 12-35-24](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/2/e2fa1966e3e6388c0aff5e07c9d84f352ebe5292.jpeg)

Currently, I can load a control file, create needles (line markup) in the scene, and re-export the data from the scene.

My biggest problem now is that I want to create a line markup from scratch (no coordinates). In fact I have to repeat/simulate the click on the “create line markup” button in the Markups module : this activates the “drawing mode” which allows to select the 2 control points of the line on the scenes.

I don’t see how to do it, nor if it is possible from a scripted module,

Could someone help me ?

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:** [April 25, 2022, 12:51pm UTC](https://discourse.slicer.org/t/create-draw-line-markup-from-scripted-module/23113/2 "2022-04-25T12:51:15Z")

</div>

You can use the markup place widget for this. See this [script repository example](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#add-a-button-to-module-gui-to-activate-control-point-placement).

---

<div class="post-metadata">

**Author:** ![llafitte007](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@llafitte007](https://discourse.slicer.org/u/llafitte007)\
**Post date:** [April 26, 2022, 8:41am UTC](https://discourse.slicer.org/t/create-draw-line-markup-from-scripted-module/23113/3 "2022-04-26T08:41:00Z")

</div>

Thanks @lassoan it was exactly was I excepted !

For those interested the code used

```auto
selectionNode = slicer.mrmlScene.GetNodeByID("vtkMRMLSelectionNodeSingleton")
selectionNode.SetReferenceActivePlaceNodeClassName("vtkMRMLMarkupsLineNode")
interactionNode = slicer.mrmlScene.GetNodeByID("vtkMRMLInteractionNodeSingleton")
interactionNode.SwitchToSinglePlaceMode()

```
