# Convert object motion path to curve

**URL:** <https://blenderartists.org/t/convert-object-motion-path-to-curve/679316>\
**Category:** Animations\
**Created:** [November 23, 2016, 12:48pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316 "2016-11-23T12:48:31Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomascheng](https://blenderartists.org/user_avatar/blenderartists.org/thomascheng/32/979408_2.png) [@thomascheng](https://blenderartists.org/u/thomascheng)\
**Post date:** [November 23, 2016, 12:48pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/1 "2016-11-23T12:48:31Z")

</div>

Hi Guys,

We are animating a simple ball flying all over the place. We would then like to take the motion path of the ball and convert it to a curve to create some solid geometry like trails. Is there a way to create a curve from the motion path of an object? Thanks.

---

<div class="post-metadata">

**Author:** ![liero](https://blenderartists.org/letter_avatar_proxy/v4/letter/l/53a042/32.png) [@liero](https://blenderartists.org/u/liero)\
**Post date:** [November 23, 2016, 5:40pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/2 "2016-11-23T17:40:03Z")

</div>

here’s an old script… select object and calculate motion path, then run script from a text editor

```auto

## path from -calculated- motion path

import bpy
ob = bpy.context.object
mp = ob.motion_path

if mp:
    path = bpy.data.curves.new('path','CURVE')
    curve = bpy.data.objects.new('Curve',path)
    bpy.context.scene.objects.link(curve)
    path.dimensions = '3D'
    spline = path.splines.new('BEZIER')
    spline.bezier_points.add(len(mp.points)-1)
    
    for i,o in enumerate(spline.bezier_points):
        o.co = mp.points[i].co
        o.handle_right_type = 'AUTO'
        o.handle_left_type = 'AUTO'

```

---

<div class="post-metadata">

**Author:** ![thomascheng](https://blenderartists.org/user_avatar/blenderartists.org/thomascheng/32/979408_2.png) [@thomascheng](https://blenderartists.org/u/thomascheng)\
**Post date:** [November 23, 2016, 8:43pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/3 "2016-11-23T20:43:27Z")

</div>

That was awesome. Thank you very much for the help. If you ever stop by New Jersey, I owe you a beer.

---

<div class="post-metadata">

**Author:** ![XeroShadow](https://blenderartists.org/user_avatar/blenderartists.org/xeroshadow/32/11947_2.png) [@XeroShadow](https://blenderartists.org/u/XeroShadow)\
**Post date:** [November 24, 2016, 10:16am UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/4 "2016-11-24T10:16:46Z")

</div>

You have posted your question in the wrong section.

---

<div class="post-metadata">

**Author:** ![thomascheng](https://blenderartists.org/user_avatar/blenderartists.org/thomascheng/32/979408_2.png) [@thomascheng](https://blenderartists.org/u/thomascheng)\
**Post date:** [November 29, 2016, 3:01pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/5 "2016-11-29T15:01:43Z")

</div>

Yeah, I just realized that. Sorry, can the mod move it for me?

---

<div class="post-metadata">

**Author:** ![XeroShadow](https://blenderartists.org/user_avatar/blenderartists.org/xeroshadow/32/11947_2.png) [@XeroShadow](https://blenderartists.org/u/XeroShadow)\
**Post date:** [November 29, 2016, 3:50pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/6 "2016-11-29T15:50:49Z")

</div>

Yes, just ask one to do so.

---

<div class="post-metadata">

**Author:** ![Rene\_Meng](https://blenderartists.org/user_avatar/blenderartists.org/rene_meng/32/720406_2.png) [@Rene\_Meng](https://blenderartists.org/u/Rene_Meng)\
**Post date:** [September 2, 2020, 10:13pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/7 "2020-09-02T22:13:21Z")

</div>

WORKING VERY WELL ON blender 2.78 (blender of 2016) thanks for the wonderful code 🙂

---

<div class="post-metadata">

**Author:** ![JohnnySix](https://blenderartists.org/user_avatar/blenderartists.org/johnnysix/32/734832_2.png) [@JohnnySix](https://blenderartists.org/u/JohnnySix)\
**Post date:** [February 28, 2021, 10:47pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/8 "2021-02-28T22:47:30Z")

</div>

I am using Blender 2.91 -

> Traceback (most recent call last):  
> File “WizardGhost\Text”, line 11, in   
> AttributeError: ‘bpy\_prop\_collection’ object has no attribute ‘link’  
> Error: Python script failed, check the message in the system console

---

<div class="post-metadata">

**Author:** ![liero](https://blenderartists.org/letter_avatar_proxy/v4/letter/l/53a042/32.png) [@liero](https://blenderartists.org/u/liero)\
**Post date:** [March 1, 2021, 6:47pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/9 "2021-03-01T18:47:34Z")

</div>

it should be a simple fix, add ‘collection’ to that line, like …context.scene.collection.objects…

```auto
## path from -calculated- motion path

import bpy
ob = bpy.context.object
mp = ob.motion_path

if mp:
    path = bpy.data.curves.new('path','CURVE')
    curve = bpy.data.objects.new('Curve',path)
    bpy.context.scene.collection.objects.link(curve)
    path.dimensions = '3D'
    spline = path.splines.new('BEZIER')
    spline.bezier_points.add(len(mp.points)-1)
    
    for i,o in enumerate(spline.bezier_points):
        o.co = mp.points[i].co
        o.handle_right_type = 'AUTO'
        o.handle_left_type = 'AUTO'

```

hope it helps

---

<div class="post-metadata">

**Author:** ![Wizard\_Semyon](https://blenderartists.org/user_avatar/blenderartists.org/wizard_semyon/32/655575_2.png) [@Wizard\_Semyon](https://blenderartists.org/u/Wizard_Semyon)\
**Post date:** [October 3, 2021, 1:42pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/10 "2021-10-03T13:42:34Z")

</div>

hello. I have so little expirience in coding. Can anybody exolain - how it use to?

---

<div class="post-metadata">

**Author:** ![liero](https://blenderartists.org/letter_avatar_proxy/v4/letter/l/53a042/32.png) [@liero](https://blenderartists.org/u/liero)\
**Post date:** [October 3, 2021, 2:29pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/11 "2021-10-03T14:29:54Z")

</div>

well, first your object should be animated, so you can go to object properties panel \> motion path \> calculate  
then make a new ‘text editor’ window, create a new text and paste the script there… or use scripting worspace  
now, with your object selected, run script from text editor window and it should generate a curve object…

 ![bakepath](https://blenderartists.org/uploads/default/original/4X/b/b/d/bbdeb14169c903a0a7c021b51b399ae5fd1167ce.jpeg)

---

<div class="post-metadata">

**Author:** ![Wizard\_Semyon](https://blenderartists.org/user_avatar/blenderartists.org/wizard_semyon/32/655575_2.png) [@Wizard\_Semyon](https://blenderartists.org/u/Wizard_Semyon)\
**Post date:** [October 3, 2021, 3:09pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/12 "2021-10-03T15:09:37Z")

</div>

thank you!

---

<div class="post-metadata">

**Author:** ![Topeich](https://blenderartists.org/user_avatar/blenderartists.org/topeich/32/864418_2.png) [@Topeich](https://blenderartists.org/u/Topeich)\
**Post date:** [July 15, 2022, 1:08pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/13 "2022-07-15T13:08:58Z")

</div>

Excelent Script!  
Thanks for sharing it 🙂

---

<div class="post-metadata">

**Author:** ![BlenderJack](https://blenderartists.org/user_avatar/blenderartists.org/blenderjack/32/1100025_2.png) [@BlenderJack](https://blenderartists.org/u/BlenderJack)\
**Post date:** [March 1, 2024, 2:14pm UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/14 "2024-03-01T14:14:10Z")

</div>

Hello, I`m using Blender 3.4 and get such errors in cycle:

> > > ```
> > > for i,o in enumerate(spline.bezier_points):
> > > 
> > > ```

File “\<blender\_console\>”, line 1  
for i,o in enumerate(spline.bezier\_points):  
IndentationError: unexpected indent

> > > ```
> > > o.co = mp.points[i].co
> > > 
> > > ```

File “\<blender\_console\>”, line 1  
[o.co](http://o.co) = mp.points[i].co  
IndentationError: unexpected indent

> > > ```
> > > o.handle_right_type = 'AUTO'
> > > 
> > > ```

File “\<blender\_console\>”, line 1  
o.handle\_right\_type = ‘AUTO’  
IndentationError: unexpected indent

> > > ```
> > > o.handle_left_type = 'AUTO'
> > > 
> > > ```

---

<div class="post-metadata">

**Author:** ![thomasfrose](https://blenderartists.org/user_avatar/blenderartists.org/thomasfrose/32/985733_2.png) [@thomasfrose](https://blenderartists.org/u/thomasfrose)\
**Post date:** [July 19, 2024, 11:11am UTC](https://blenderartists.org/t/convert-object-motion-path-to-curve/679316/15 "2024-07-19T11:11:12Z")

</div>

Works in Blender 4.0.2. Thank you!
