Transfer Spline Points Between Blueprints?

I have existing splines created using a blueprint and I’d like to use the spline point data in a new blueprint. Anyone have any advice?

2 Likes

ALT-drag?

You can also write a BP to copy the point data from the other.

2 Likes

This is what I’d like to know how to do.

If the original BP is ‘SplineBP’, then in a new BP, we can use a reference and copy the data out

This only does relative location, but of course you can copy the whole transform.

But why bother? :slight_smile:

Any idea why mine isn’t working?

copySpline1

Updated code ( tested this time ).

copy spline

That works! Any way to store the spline points so that I can delete the originals?

Store them for how long?

What originals, the ones in the other BP?

Saving the level will store everything, of course.

Actually as long as I keep it in a function (instead of on the construction script) it retains the spline points. Thanks for the help @ClockworkOcean ! Here’s my final blueprint:

3 Likes

Lovely :slight_smile:

I’ve copied your code and am running it in a Fn on the CS but I could only get the changes to save if I set ‘Override Construction Script’ = ON on the details panel for the spline component in level. If I ever uncheck this, it reverts back to default.

Hello where to put these codes? create a new BP or level blueprint?

1 Like

New BP. It’s the one with the spline in :slight_smile:

1 Like

i also tried it , it is not permanent, when i edit or change something, it reverts back to original shape. is there any way to make these points identical, i mean like normal spline actor.

I know it is already solved, but in case somebody needs it I created a python script to copy the spline points. you just have to specify the names and run it inside the level

import unreal

editor_actor_subsystem = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)

source_bp_actor = None
destination_bp_actor = None

all_actors = editor_actor_subsystem.get_all_level_actors()

for actor in all_actors:
    if actor.get_actor_label() == "BP_Spline_Source_Name":
        source_bp_actor = actor

    if actor.get_actor_label() == "BP_Spline_Destination_Name":
        destination_bp_actor = actor


source_spline = None
destination_spline = None

source_components = source_bp_actor.get_components_by_class(unreal.SplineComponent)
if source_components:
    source_spline = source_components[0]

destination_components = destination_bp_actor.get_components_by_class(unreal.SplineComponent)
if destination_components:
    destination_spline = destination_components[0]

# Clear existing points in the destination spline
destination_spline.clear_spline_points()

# Iterate over the points in the source spline and add them to the destination spline
num_points = source_spline.get_number_of_spline_points()
for i in range(num_points):
    # Get the point's position, tangent, rotation, scale and type
    location = source_spline.get_location_at_spline_point(i, unreal.SplineCoordinateSpace.LOCAL)
    tangent = source_spline.get_arrive_tangent_at_spline_point(i, unreal.SplineCoordinateSpace.LOCAL)
    rotation = source_spline.get_rotation_at_spline_point(i, unreal.SplineCoordinateSpace.LOCAL)
    scale = source_spline.get_scale_at_spline_point(i)
    point_type = source_spline.get_spline_point_type(i)
    
    # Add a spline point at the location and immediately update the spline
    destination_spline.add_spline_point_at_index(location, i, unreal.SplineCoordinateSpace.LOCAL, update_spline=True)
    destination_spline.set_tangent_at_spline_point(i, tangent, unreal.SplineCoordinateSpace.LOCAL)
    destination_spline.set_rotation_at_spline_point(i, rotation, unreal.SplineCoordinateSpace.LOCAL)
    destination_spline.set_scale_at_spline_point(i, scale)
    destination_spline.set_spline_point_type(i, point_type, update_spline=True)

unreal.EditorUtilityLibrary().set_actor_property(destination_bp_actor, "Modify", True)
destination_spline.update_spline()

If the points disappear when you move it just select all of them and save the level.

Hey this Python script is exactly what I’m looking for, but when I run it I get an error:

AttributeError: 'EditorUtilityLibrary' object has no attribute 'set_actor_property'

Any idea why that would be?

EDIT: Nevermind, it seems like it worked despite the error. Awesome script!