# Script for copy pate Spline Component

**URL:** <https://forums.unrealengine.com/t/script-for-copy-pate-spline-component/1742698>\
**Category:** Pipeline & Plugins\
**Tags:** Python, copy, splinecomponent, unreal-engine, Spline\
**Created:** [March 10, 2024, 9:47am UTC](https://forums.unrealengine.com/t/script-for-copy-pate-spline-component/1742698 "2024-03-10T09:47:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpotuznik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dpotuznik](https://forums.unrealengine.com/u/dpotuznik)\
**Post date:** [March 10, 2024, 9:47am UTC](https://forums.unrealengine.com/t/script-for-copy-pate-spline-component/1742698/1 "2024-03-10T09:47:59Z")

</div>

Hi ,

juste a quick tips.  
i wanted to copy the spline component from the old cameraRig\_Rail to the new CineCameraRig\_Rail , so i made a little script.

usage :  
select source cameraRigRail  
select target cineCameraRigRail  
type in cmd line : py yourPath/getReferenceSelectedSpline.py

I think I can work on other tool , you select the actor and the script look if an splineComponent exist

getReferenceSelectedSpline.py

```auto
import unreal

# Get the Editor Actor Subsystem
actor_subsystem = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)

# Get the list of currently selected level actors
selected_actors = actor_subsystem.get_selected_level_actors()

# Check if at least two actors are selected (assuming you want to copy from one and paste to another)
if len(selected_actors) >= 2:
    # Assuming the first selected actor is the source and the second is the destination
    source_actor = selected_actors[0]
    target_actor = selected_actors[1]

    # Attempt to find a SplineComponent within each selected actor
    source_spline = source_actor.get_component_by_class(unreal.SplineComponent)
    target_spline = target_actor.get_component_by_class(unreal.SplineComponent)
    
    if source_spline and target_spline:
        # Clear existing points in the target spline
        target_spline.clear_spline_points(True)

        # Get the number of points in the source spline
        num_points = source_spline.get_number_of_spline_points()

        # Copy each point from the source spline to the target spline
        for point_index in range(num_points):
            # Get location and tangent of the current point in the source spline
            location = source_spline.get_location_at_spline_point(point_index, unreal.SplineCoordinateSpace.WORLD)
            arrival_tangent = source_spline.get_arrive_tangent_at_spline_point(point_index, unreal.SplineCoordinateSpace.WORLD)
            departure_tangent = source_spline.get_leave_tangent_at_spline_point(point_index, unreal.SplineCoordinateSpace.WORLD)

            # Add a new point to the target spline with the copied location and tangent
            target_spline.add_spline_point_at_index(location, point_index, unreal.SplineCoordinateSpace.WORLD, True)
            target_spline.set_tangents_at_spline_point(point_index,arrival_tangent, departure_tangent, unreal.SplineCoordinateSpace.WORLD,True)

        print("Spline points copied successfully from source to target.")
    else:
        print("A SplineComponent could not be found in one of the selected actors.")
else:
    print("Please select at least two actors with SplineComponents in the Unreal Editor.")

```

---

<div class="post-metadata">

**Author:** ![Aakrasia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aakrasia](https://forums.unrealengine.com/u/Aakrasia)\
**Post date:** [July 1, 2024, 8:02pm UTC](https://forums.unrealengine.com/t/script-for-copy-pate-spline-component/1742698/2 "2024-07-01T20:02:06Z")

</div>

Hey great one, works like a charm, thanks.

---

<div class="post-metadata">

**Author:** ![Fabri\_Gamba1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fabri\_Gamba1](https://forums.unrealengine.com/u/Fabri_Gamba1)\
**Post date:** [May 20, 2025, 10:06am UTC](https://forums.unrealengine.com/t/script-for-copy-pate-spline-component/1742698/3 "2025-05-20T10:06:33Z")

</div>

> [@dpotuznik](#):
>
> getReferenceSelectedSpline.py

Excellent! Very useful! Thank you so much!
