# Move a model along a straight line by script

**URL:** <https://discourse.slicer.org/t/move-a-model-along-a-straight-line-by-script/28046>\
**Category:** Community\
**Created:** [February 25, 2023, 7:49am UTC](https://discourse.slicer.org/t/move-a-model-along-a-straight-line-by-script/28046 "2023-02-25T07:49:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![slicer365](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/slicer365/32/67549_2.png) [@slicer365](https://discourse.slicer.org/u/slicer365)\
**Post date:** [February 25, 2023, 7:49am UTC](https://discourse.slicer.org/t/move-a-model-along-a-straight-line-by-script/28046/1 "2023-02-25T07:49:16Z")

</div>

Dear friends  
I have creat a model by Slicer, I can get the model’s node ID,

now I want to move the model along a straight line by script, let the direction of movement is parallel to this line.

I can creat a line by Markups module, then get the line’s nodeID.

or I just get two points’RAS on the line

Anyone can tell me how to write a python script? Thank you!

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/1/21b5199aa30a6c0c943a8b2707b0af6bb53f16f3.png)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [February 25, 2023, 5:14pm UTC](https://discourse.slicer.org/t/move-a-model-along-a-straight-line-by-script/28046/2 "2023-02-25T17:14:27Z")

</div>

You should be able to copy the way the [endoscopy module](https://github.com/Slicer/Slicer/blob/main/Modules/Scripted/Endoscopy/Endoscopy.py) does this. Look for the `self.transform` and how it is used to move the cursor model along the path.
