Retrieve a spline shape and reapply it to another spline

I have a level with a bunch of splines (200+), I’d need to retrieve the “shape” of each spline and reapply it to another spline, the goal being replacing all existing splines with others without re doing all by hand.
Any advice ?

2 Likes

You can write a blueprint that will take two actors with spline components as input. It can loop down one spline and apply the transforms to the other spline?

Hi,

I made a tool to copy/paste the spline data to/from the clipboard for things like that.

rdSplineTools on the marketplace.

1 Like

Seems like a good way to do it yes. Could you help a bit more on how to proceed ?

Hi RD,
I already own RdInst & RdBPTools, I can’t spend another 20€ on a plugin, especially for a spline plugin, I don’t use spline that often, except in PCG.
Thanks anyway for suggesting it!

1 Like

Yes, but can’t actually paste any code until much later, as I’m not a machine rn.

I’m assuming you know the typical nodes for processing a spline?

‘number of spline points’
‘get transform at spline point’

etc…

And you just walk done spline A, applying what you find to spline B.

Do you just have blueprints with spline components in the map?

1 Like

I think I know the big steps yes.
Do splines need to have the same points number ?

Yes? It’s a vineyard, and each vine row is a BP with a spline component.

SplineTool.zip (68.9 KB)

Made a editor tool to copy spline component information.

It copies splines directly source to target in local space.

Tools in 5.4

Edit: updated spline display names to encompass the parent object name
Ok still need the asset to save on update…

3 Likes

Thank you so much! It’s perfect for the use I need. Merci!

Edit final update
SplineTool.zip (58.8 KB)

Will save asset, added in an option to automatically save the level (checkbox).
Final edits only work when the level itself is saved with the assets (so set it to true as default).

Should it try to recreate the amount of points on the target spline or just cut it off to where they mismatch?

3 Likes

If it could try to recreate the missing amount of points it’d be a m a z i n g!

@someonelsee1 Updated:
SplineToolsTangentsOK.zip (72.9 KB)

Edit: fixed up the curve type copy (it needed an extra override in the target spline component)

1 Like

mmmh still doesn’t work for me, I mean yeah it works, but as soon as I move the spline, it resets to its default
I can fix that by ticking “Override Construction Script” in the target spline before moving it!

edit: it doesn’t work with the BP spline I was using, but I tried with a newly created BP with a spline and it works as intended.
Anywayyy thank you x100 for your time!

seems it needs to set bSplineHasBeenEdited = true to trigger the override construction script. Unfortunately there is no direct access via blueprint.
It would be done if I switched to c++.

1 Like

oookay nice to know! I’ll dig into C++ one day. thanks!

Update to the c++ part. Just needs 1 blueprint function library entry

header

class USplineComponent;

UCLASS()
class YOURGAME_API USplineFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintCallable)
	static void UpdateOverrideComponent(UPARAM(ref) USplineComponent* spline);

};

cpp

#include "SplineFunctionLibrary.h"
#include "Components/SplineComponent.h"

void USplineFunctionLibrary::UpdateOverrideComponent(UPARAM(ref) USplineComponent* spline)
{
	if (spline != nullptr) {
		spline->bModifiedByConstructionScript = true;	
		spline->bSplineHasBeenEdited = true;		
		spline->bInputSplinePointsToConstructionScript = true;
		spline->MarkPackageDirty();
		spline->MarkRenderStateDirty();
		spline->UpdateSpline();
	}
}

Updated editor widget with static call
SplineTool_StaticLib.zip (75.1 KB)

1 Like

omg you really went all the way, thank you :star_struck:
I wish everyone is this forum was helpful as you are!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.